18#ifndef INCLUDE_NLOHMANN_JSON_HPP_
19#define INCLUDE_NLOHMANN_JSON_HPP_
24#include <initializer_list>
60#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
61 #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH)
62 #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 12 || NLOHMANN_JSON_VERSION_PATCH != 0
63 #warning "Already included a different version of the library!"
68#define NLOHMANN_JSON_VERSION_MAJOR 3
69#define NLOHMANN_JSON_VERSION_MINOR 12
70#define NLOHMANN_JSON_VERSION_PATCH 0
72#ifndef JSON_DIAGNOSTICS
73 #define JSON_DIAGNOSTICS 0
76#ifndef JSON_DIAGNOSTIC_POSITIONS
77 #define JSON_DIAGNOSTIC_POSITIONS 0
80#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
81 #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
85 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag
87 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS
90#if JSON_DIAGNOSTIC_POSITIONS
91 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS _dp
93 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS
96#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
97 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp
99 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
102#ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION
103 #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0
107#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b, c) json_abi ## a ## b ## c
108#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b, c) \
109 NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b, c)
111#define NLOHMANN_JSON_ABI_TAGS \
112 NLOHMANN_JSON_ABI_TAGS_CONCAT( \
113 NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \
114 NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON, \
115 NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS)
118#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \
119 _v ## major ## _ ## minor ## _ ## patch
120#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \
121 NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch)
123#if NLOHMANN_JSON_NAMESPACE_NO_VERSION
124#define NLOHMANN_JSON_NAMESPACE_VERSION
126#define NLOHMANN_JSON_NAMESPACE_VERSION \
127 NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \
128 NLOHMANN_JSON_VERSION_MINOR, \
129 NLOHMANN_JSON_VERSION_PATCH)
133#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b
134#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \
135 NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b)
137#ifndef NLOHMANN_JSON_NAMESPACE
138#define NLOHMANN_JSON_NAMESPACE \
139 nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \
140 NLOHMANN_JSON_ABI_TAGS, \
141 NLOHMANN_JSON_NAMESPACE_VERSION)
144#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN
145#define NLOHMANN_JSON_NAMESPACE_BEGIN \
148 inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \
149 NLOHMANN_JSON_ABI_TAGS, \
150 NLOHMANN_JSON_NAMESPACE_VERSION) \
154#ifndef NLOHMANN_JSON_NAMESPACE_END
155#define NLOHMANN_JSON_NAMESPACE_END \
173#include <forward_list>
178#include <type_traits>
179#include <unordered_map>
242#include <type_traits>
287template<
class Default,
289 template<
class...>
class Op,
297template<
class Default,
template<
class...>
class Op,
class... Args>
304template<
template<
class...>
class Op,
class... Args>
307template<
template<
class...>
class Op,
class... Args>
310template<
template<
class...>
class Op,
class... Args>
313template<
class Default,
template<
class...>
class Op,
class... Args>
316template<
class Default,
template<
class...>
class Op,
class... Args>
319template<
class Expected,
template<
class...>
class Op,
class... Args>
322template<
class To,
template<
class...>
class Op,
class... Args>
324 std::is_convertible<
detected_t<Op, Args...>, To>;
345#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15)
346#if defined(JSON_HEDLEY_VERSION)
347 #undef JSON_HEDLEY_VERSION
349#define JSON_HEDLEY_VERSION 15
351#if defined(JSON_HEDLEY_STRINGIFY_EX)
352 #undef JSON_HEDLEY_STRINGIFY_EX
354#define JSON_HEDLEY_STRINGIFY_EX(x) #x
356#if defined(JSON_HEDLEY_STRINGIFY)
357 #undef JSON_HEDLEY_STRINGIFY
359#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x)
361#if defined(JSON_HEDLEY_CONCAT_EX)
362 #undef JSON_HEDLEY_CONCAT_EX
364#define JSON_HEDLEY_CONCAT_EX(a,b) a##b
366#if defined(JSON_HEDLEY_CONCAT)
367 #undef JSON_HEDLEY_CONCAT
369#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
371#if defined(JSON_HEDLEY_CONCAT3_EX)
372 #undef JSON_HEDLEY_CONCAT3_EX
374#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
376#if defined(JSON_HEDLEY_CONCAT3)
377 #undef JSON_HEDLEY_CONCAT3
379#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
381#if defined(JSON_HEDLEY_VERSION_ENCODE)
382 #undef JSON_HEDLEY_VERSION_ENCODE
384#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision))
386#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR)
387 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
389#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
391#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR)
392 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
394#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
396#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION)
397 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
399#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
401#if defined(JSON_HEDLEY_GNUC_VERSION)
402 #undef JSON_HEDLEY_GNUC_VERSION
404#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
405 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
406#elif defined(__GNUC__)
407 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
410#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK)
411 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
413#if defined(JSON_HEDLEY_GNUC_VERSION)
414 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
416 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0)
419#if defined(JSON_HEDLEY_MSVC_VERSION)
420 #undef JSON_HEDLEY_MSVC_VERSION
422#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL)
423 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100)
424#elif defined(_MSC_FULL_VER) && !defined(__ICL)
425 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
426#elif defined(_MSC_VER) && !defined(__ICL)
427 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
430#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
431 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
433#if !defined(JSON_HEDLEY_MSVC_VERSION)
434 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0)
435#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
436 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
437#elif defined(_MSC_VER) && (_MSC_VER >= 1200)
438 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
440 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor)))
443#if defined(JSON_HEDLEY_INTEL_VERSION)
444 #undef JSON_HEDLEY_INTEL_VERSION
446#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL)
447 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
448#elif defined(__INTEL_COMPILER) && !defined(__ICL)
449 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
452#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK)
453 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
455#if defined(JSON_HEDLEY_INTEL_VERSION)
456 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
458 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0)
461#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
462 #undef JSON_HEDLEY_INTEL_CL_VERSION
464#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
465 #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
468#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
469 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
471#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
472 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
474 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0)
477#if defined(JSON_HEDLEY_PGI_VERSION)
478 #undef JSON_HEDLEY_PGI_VERSION
480#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
481 #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
484#if defined(JSON_HEDLEY_PGI_VERSION_CHECK)
485 #undef JSON_HEDLEY_PGI_VERSION_CHECK
487#if defined(JSON_HEDLEY_PGI_VERSION)
488 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
490 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0)
493#if defined(JSON_HEDLEY_SUNPRO_VERSION)
494 #undef JSON_HEDLEY_SUNPRO_VERSION
496#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
497 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10)
498#elif defined(__SUNPRO_C)
499 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
500#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
501 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10)
502#elif defined(__SUNPRO_CC)
503 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
506#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
507 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
509#if defined(JSON_HEDLEY_SUNPRO_VERSION)
510 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
512 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0)
515#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
516 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
518#if defined(__EMSCRIPTEN__)
519 #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
522#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
523 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
525#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
526 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
528 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0)
531#if defined(JSON_HEDLEY_ARM_VERSION)
532 #undef JSON_HEDLEY_ARM_VERSION
534#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
535 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100)
536#elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
537 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100)
540#if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
541 #undef JSON_HEDLEY_ARM_VERSION_CHECK
543#if defined(JSON_HEDLEY_ARM_VERSION)
544 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
546 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0)
549#if defined(JSON_HEDLEY_IBM_VERSION)
550 #undef JSON_HEDLEY_IBM_VERSION
552#if defined(__ibmxl__)
553 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
554#elif defined(__xlC__) && defined(__xlC_ver__)
555 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
556#elif defined(__xlC__)
557 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
560#if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
561 #undef JSON_HEDLEY_IBM_VERSION_CHECK
563#if defined(JSON_HEDLEY_IBM_VERSION)
564 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
566 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0)
569#if defined(JSON_HEDLEY_TI_VERSION)
570 #undef JSON_HEDLEY_TI_VERSION
573 defined(__TI_COMPILER_VERSION__) && \
575 defined(__TMS470__) || defined(__TI_ARM__) || \
576 defined(__MSP430__) || \
577 defined(__TMS320C2000__) \
579#if (__TI_COMPILER_VERSION__ >= 16000000)
580 #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
584#if defined(JSON_HEDLEY_TI_VERSION_CHECK)
585 #undef JSON_HEDLEY_TI_VERSION_CHECK
587#if defined(JSON_HEDLEY_TI_VERSION)
588 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
590 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
593#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
594 #undef JSON_HEDLEY_TI_CL2000_VERSION
596#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
597 #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
600#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
601 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
603#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
604 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
606 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
609#if defined(JSON_HEDLEY_TI_CL430_VERSION)
610 #undef JSON_HEDLEY_TI_CL430_VERSION
612#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
613 #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
616#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
617 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
619#if defined(JSON_HEDLEY_TI_CL430_VERSION)
620 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
622 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
625#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
626 #undef JSON_HEDLEY_TI_ARMCL_VERSION
628#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
629 #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
632#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
633 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
635#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
636 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
638 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
641#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
642 #undef JSON_HEDLEY_TI_CL6X_VERSION
644#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
645 #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
648#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
649 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
651#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
652 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
654 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
657#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
658 #undef JSON_HEDLEY_TI_CL7X_VERSION
660#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
661 #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
664#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
665 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
667#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
668 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
670 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
673#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
674 #undef JSON_HEDLEY_TI_CLPRU_VERSION
676#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
677 #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
680#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
681 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
683#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
684 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
686 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
689#if defined(JSON_HEDLEY_CRAY_VERSION)
690 #undef JSON_HEDLEY_CRAY_VERSION
693 #if defined(_RELEASE_PATCHLEVEL)
694 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
696 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
700#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
701 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
703#if defined(JSON_HEDLEY_CRAY_VERSION)
704 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
706 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0)
709#if defined(JSON_HEDLEY_IAR_VERSION)
710 #undef JSON_HEDLEY_IAR_VERSION
712#if defined(__IAR_SYSTEMS_ICC__)
714 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
716 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0)
720#if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
721 #undef JSON_HEDLEY_IAR_VERSION_CHECK
723#if defined(JSON_HEDLEY_IAR_VERSION)
724 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
726 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0)
729#if defined(JSON_HEDLEY_TINYC_VERSION)
730 #undef JSON_HEDLEY_TINYC_VERSION
732#if defined(__TINYC__)
733 #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
736#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
737 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
739#if defined(JSON_HEDLEY_TINYC_VERSION)
740 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
742 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0)
745#if defined(JSON_HEDLEY_DMC_VERSION)
746 #undef JSON_HEDLEY_DMC_VERSION
749 #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
752#if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
753 #undef JSON_HEDLEY_DMC_VERSION_CHECK
755#if defined(JSON_HEDLEY_DMC_VERSION)
756 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
758 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0)
761#if defined(JSON_HEDLEY_COMPCERT_VERSION)
762 #undef JSON_HEDLEY_COMPCERT_VERSION
764#if defined(__COMPCERT_VERSION__)
765 #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100)
768#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
769 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
771#if defined(JSON_HEDLEY_COMPCERT_VERSION)
772 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
774 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0)
777#if defined(JSON_HEDLEY_PELLES_VERSION)
778 #undef JSON_HEDLEY_PELLES_VERSION
781 #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
784#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
785 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
787#if defined(JSON_HEDLEY_PELLES_VERSION)
788 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
790 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
793#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
794 #undef JSON_HEDLEY_MCST_LCC_VERSION
796#if defined(__LCC__) && defined(__LCC_MINOR__)
797 #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__)
800#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK)
801 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
803#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
804 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
806 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0)
809#if defined(JSON_HEDLEY_GCC_VERSION)
810 #undef JSON_HEDLEY_GCC_VERSION
813 defined(JSON_HEDLEY_GNUC_VERSION) && \
814 !defined(__clang__) && \
815 !defined(JSON_HEDLEY_INTEL_VERSION) && \
816 !defined(JSON_HEDLEY_PGI_VERSION) && \
817 !defined(JSON_HEDLEY_ARM_VERSION) && \
818 !defined(JSON_HEDLEY_CRAY_VERSION) && \
819 !defined(JSON_HEDLEY_TI_VERSION) && \
820 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
821 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \
822 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
823 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
824 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
825 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
826 !defined(__COMPCERT__) && \
827 !defined(JSON_HEDLEY_MCST_LCC_VERSION)
828 #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
831#if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
832 #undef JSON_HEDLEY_GCC_VERSION_CHECK
834#if defined(JSON_HEDLEY_GCC_VERSION)
835 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
837 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0)
840#if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
841 #undef JSON_HEDLEY_HAS_ATTRIBUTE
844 defined(__has_attribute) && \
846 (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \
848# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
850# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
853#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
854 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
856#if defined(__has_attribute)
857 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
859 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
862#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
863 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
865#if defined(__has_attribute)
866 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
868 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
871#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
872 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
875 defined(__has_cpp_attribute) && \
876 defined(__cplusplus) && \
877 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0))
878 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
880 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
883#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
884 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
886#if !defined(__cplusplus) || !defined(__has_cpp_attribute)
887 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
889 !defined(JSON_HEDLEY_PGI_VERSION) && \
890 !defined(JSON_HEDLEY_IAR_VERSION) && \
891 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
892 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
893 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
895 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
898#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
899 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
901#if defined(__has_cpp_attribute) && defined(__cplusplus)
902 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
904 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
907#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
908 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
910#if defined(__has_cpp_attribute) && defined(__cplusplus)
911 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
913 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
916#if defined(JSON_HEDLEY_HAS_BUILTIN)
917 #undef JSON_HEDLEY_HAS_BUILTIN
919#if defined(__has_builtin)
920 #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
922 #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
925#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
926 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
928#if defined(__has_builtin)
929 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
931 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
934#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
935 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
937#if defined(__has_builtin)
938 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
940 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
943#if defined(JSON_HEDLEY_HAS_FEATURE)
944 #undef JSON_HEDLEY_HAS_FEATURE
946#if defined(__has_feature)
947 #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
949 #define JSON_HEDLEY_HAS_FEATURE(feature) (0)
952#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
953 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
955#if defined(__has_feature)
956 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
958 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
961#if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
962 #undef JSON_HEDLEY_GCC_HAS_FEATURE
964#if defined(__has_feature)
965 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
967 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
970#if defined(JSON_HEDLEY_HAS_EXTENSION)
971 #undef JSON_HEDLEY_HAS_EXTENSION
973#if defined(__has_extension)
974 #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
976 #define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
979#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
980 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
982#if defined(__has_extension)
983 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
985 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
988#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
989 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
991#if defined(__has_extension)
992 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
994 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
997#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
998 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
1000#if defined(__has_declspec_attribute)
1001 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
1003 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
1006#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
1007 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
1009#if defined(__has_declspec_attribute)
1010 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
1012 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1015#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
1016 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
1018#if defined(__has_declspec_attribute)
1019 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
1021 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1024#if defined(JSON_HEDLEY_HAS_WARNING)
1025 #undef JSON_HEDLEY_HAS_WARNING
1027#if defined(__has_warning)
1028 #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
1030 #define JSON_HEDLEY_HAS_WARNING(warning) (0)
1033#if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
1034 #undef JSON_HEDLEY_GNUC_HAS_WARNING
1036#if defined(__has_warning)
1037 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1039 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1042#if defined(JSON_HEDLEY_GCC_HAS_WARNING)
1043 #undef JSON_HEDLEY_GCC_HAS_WARNING
1045#if defined(__has_warning)
1046 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1048 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1052 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1053 defined(__clang__) || \
1054 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1055 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1056 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1057 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
1058 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1059 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1060 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1061 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1062 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1063 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
1064 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1065 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1066 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
1067 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
1068 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
1069 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
1070 #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
1071#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1072 #define JSON_HEDLEY_PRAGMA(value) __pragma(value)
1074 #define JSON_HEDLEY_PRAGMA(value)
1077#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
1078 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
1080#if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
1081 #undef JSON_HEDLEY_DIAGNOSTIC_POP
1083#if defined(__clang__)
1084 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
1085 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
1086#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1087 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1088 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1089#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1090 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
1091 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
1093 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
1094 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1095 #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
1096 #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
1097#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
1098 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
1099 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
1101 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1102 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1103 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
1104 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1105 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1106 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1107 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
1108 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
1109#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1110 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1111 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1113 #define JSON_HEDLEY_DIAGNOSTIC_PUSH
1114 #define JSON_HEDLEY_DIAGNOSTIC_POP
1119#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1120 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
1122#if defined(__cplusplus)
1123# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
1124# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
1125# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
1126# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1127 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1128 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1129 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1130 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \
1132 JSON_HEDLEY_DIAGNOSTIC_POP
1134# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1135 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1136 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1137 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1139 JSON_HEDLEY_DIAGNOSTIC_POP
1142# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1143 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1144 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1146 JSON_HEDLEY_DIAGNOSTIC_POP
1150#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1151 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
1154#if defined(JSON_HEDLEY_CONST_CAST)
1155 #undef JSON_HEDLEY_CONST_CAST
1157#if defined(__cplusplus)
1158# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
1160 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
1161 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
1162 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1163# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
1164 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1165 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
1167 JSON_HEDLEY_DIAGNOSTIC_POP \
1170# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
1173#if defined(JSON_HEDLEY_REINTERPRET_CAST)
1174 #undef JSON_HEDLEY_REINTERPRET_CAST
1176#if defined(__cplusplus)
1177 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
1179 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
1182#if defined(JSON_HEDLEY_STATIC_CAST)
1183 #undef JSON_HEDLEY_STATIC_CAST
1185#if defined(__cplusplus)
1186 #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
1188 #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
1191#if defined(JSON_HEDLEY_CPP_CAST)
1192 #undef JSON_HEDLEY_CPP_CAST
1194#if defined(__cplusplus)
1195# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
1196# define JSON_HEDLEY_CPP_CAST(T, expr) \
1197 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1198 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
1200 JSON_HEDLEY_DIAGNOSTIC_POP
1201# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
1202# define JSON_HEDLEY_CPP_CAST(T, expr) \
1203 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1204 _Pragma("diag_suppress=Pe137") \
1205 JSON_HEDLEY_DIAGNOSTIC_POP
1207# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
1210# define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
1213#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
1214 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1216#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
1217 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
1218#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1219 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
1220#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1221 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786))
1222#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1223 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
1224#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1225 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1226#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1227 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1228#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1229 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
1230#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1231 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1233 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1234 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1235 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1236 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1237 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1238 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1239 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1240 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1241 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1242 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1243 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1244 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
1245#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
1246 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
1247#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
1248 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
1249#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1250 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
1251#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1252 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
1254 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1257#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
1258 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1260#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1261 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
1262#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1263 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
1264#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1265 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161))
1266#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1267 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
1268#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1269 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
1270#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1271 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
1273 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
1274 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1275 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1276 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
1277 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1278#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
1279 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1280#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1281 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
1282#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1283 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161")
1285 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1288#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
1289 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1291#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes")
1292 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
1293#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1294 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1295#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
1296 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
1297#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1298 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
1299#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
1300 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
1301#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1302 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
1303#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1304 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1305#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
1306 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
1308 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1309 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1310 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
1311 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
1312#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1313 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
1314#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1315 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1317 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1320#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
1321 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1323#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual")
1324 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
1325#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1326 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)")
1327#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0)
1328 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
1330 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1333#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION)
1334 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1336#if JSON_HEDLEY_HAS_WARNING("-Wunused-function")
1337 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
1338#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0)
1339 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
1340#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0)
1341 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505))
1342#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1343 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142")
1345 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1348#if defined(JSON_HEDLEY_DEPRECATED)
1349 #undef JSON_HEDLEY_DEPRECATED
1351#if defined(JSON_HEDLEY_DEPRECATED_FOR)
1352 #undef JSON_HEDLEY_DEPRECATED_FOR
1355 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1356 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1357 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
1358 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
1360 (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1361 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1362 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1363 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1364 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
1365 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1366 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1367 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
1368 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1369 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1370 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \
1371 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1372 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
1373 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
1374#elif defined(__cplusplus) && (__cplusplus >= 201402L)
1375 #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
1376 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
1378 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
1379 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1380 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1381 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1382 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1383 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1384 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1385 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1386 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1387 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1388 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1389 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1390 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1391 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1392 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1393 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1394 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
1395 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
1397 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1398 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \
1399 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1400 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
1401 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
1402#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1403 #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
1404 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
1406 #define JSON_HEDLEY_DEPRECATED(since)
1407 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
1410#if defined(JSON_HEDLEY_UNAVAILABLE)
1411 #undef JSON_HEDLEY_UNAVAILABLE
1414 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
1415 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
1416 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1417 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1418 #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
1420 #define JSON_HEDLEY_UNAVAILABLE(available_since)
1423#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
1424 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
1426#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
1427 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
1430 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
1431 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1432 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1433 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1434 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1435 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1436 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1437 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1438 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1439 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1440 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1441 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1442 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1443 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1444 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1445 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1446 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1447 #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
1448 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
1449#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1450 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1451 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1452#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1453 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1454 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1455#elif defined(_Check_return_)
1456 #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
1457 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
1459 #define JSON_HEDLEY_WARN_UNUSED_RESULT
1460 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
1463#if defined(JSON_HEDLEY_SENTINEL)
1464 #undef JSON_HEDLEY_SENTINEL
1467 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
1468 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1469 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1470 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1471 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1472 #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
1474 #define JSON_HEDLEY_SENTINEL(position)
1477#if defined(JSON_HEDLEY_NO_RETURN)
1478 #undef JSON_HEDLEY_NO_RETURN
1480#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1481 #define JSON_HEDLEY_NO_RETURN __noreturn
1483 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1484 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1485 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1486#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1487 #define JSON_HEDLEY_NO_RETURN _Noreturn
1488#elif defined(__cplusplus) && (__cplusplus >= 201103L)
1489 #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
1491 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \
1492 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \
1493 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1494 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1495 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1496 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1497 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1498 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1499 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1500 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1501 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1502 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1503 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1504 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1505 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1506 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1507 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1508 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1509#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1510 #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
1512 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1513 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1514 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1515#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1516 #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
1517#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1518 #define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
1519#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1520 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1522 #define JSON_HEDLEY_NO_RETURN
1525#if defined(JSON_HEDLEY_NO_ESCAPE)
1526 #undef JSON_HEDLEY_NO_ESCAPE
1528#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
1529 #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
1531 #define JSON_HEDLEY_NO_ESCAPE
1534#if defined(JSON_HEDLEY_UNREACHABLE)
1535 #undef JSON_HEDLEY_UNREACHABLE
1537#if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
1538 #undef JSON_HEDLEY_UNREACHABLE_RETURN
1540#if defined(JSON_HEDLEY_ASSUME)
1541 #undef JSON_HEDLEY_ASSUME
1544 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1545 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1546 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1547 #define JSON_HEDLEY_ASSUME(expr) __assume(expr)
1548#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
1549 #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
1551 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1552 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1553 #if defined(__cplusplus)
1554 #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
1556 #define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
1560 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
1561 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1562 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
1563 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1564 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \
1565 JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \
1566 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1567 #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
1568#elif defined(JSON_HEDLEY_ASSUME)
1569 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1571#if !defined(JSON_HEDLEY_ASSUME)
1572 #if defined(JSON_HEDLEY_UNREACHABLE)
1573 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
1575 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
1578#if defined(JSON_HEDLEY_UNREACHABLE)
1580 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1581 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1582 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
1584 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
1587 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
1589#if !defined(JSON_HEDLEY_UNREACHABLE)
1590 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1594#if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
1595 #pragma clang diagnostic ignored "-Wpedantic"
1597#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
1598 #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
1600#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0)
1601 #if defined(__clang__)
1602 #pragma clang diagnostic ignored "-Wvariadic-macros"
1603 #elif defined(JSON_HEDLEY_GCC_VERSION)
1604 #pragma GCC diagnostic ignored "-Wvariadic-macros"
1607#if defined(JSON_HEDLEY_NON_NULL)
1608 #undef JSON_HEDLEY_NON_NULL
1611 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \
1612 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1613 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1614 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1615 #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
1617 #define JSON_HEDLEY_NON_NULL(...)
1621#if defined(JSON_HEDLEY_PRINTF_FORMAT)
1622 #undef JSON_HEDLEY_PRINTF_FORMAT
1624#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO)
1625 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check)))
1626#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO)
1627 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
1629 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \
1630 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1631 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1632 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1633 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1634 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1635 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1636 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1637 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1638 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1639 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1640 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1641 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1642 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1643 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1644 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1645 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1646 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
1647#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
1648 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
1650 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
1653#if defined(JSON_HEDLEY_CONSTEXPR)
1654 #undef JSON_HEDLEY_CONSTEXPR
1656#if defined(__cplusplus)
1657 #if __cplusplus >= 201103L
1658 #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
1661#if !defined(JSON_HEDLEY_CONSTEXPR)
1662 #define JSON_HEDLEY_CONSTEXPR
1665#if defined(JSON_HEDLEY_PREDICT)
1666 #undef JSON_HEDLEY_PREDICT
1668#if defined(JSON_HEDLEY_LIKELY)
1669 #undef JSON_HEDLEY_LIKELY
1671#if defined(JSON_HEDLEY_UNLIKELY)
1672 #undef JSON_HEDLEY_UNLIKELY
1674#if defined(JSON_HEDLEY_UNPREDICTABLE)
1675 #undef JSON_HEDLEY_UNPREDICTABLE
1677#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
1678 #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
1681 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
1682 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \
1683 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1684# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
1685# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
1686# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
1687# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
1688# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
1690 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1691 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1692 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1693 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1694 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1695 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1696 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1697 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1698 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1699 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1700 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1701 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1702 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1703 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
1704 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1705 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1706# define JSON_HEDLEY_PREDICT(expr, expected, probability) \
1707 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
1708# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
1710 double hedley_probability_ = (probability); \
1711 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
1713# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
1715 double hedley_probability_ = (probability); \
1716 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
1718# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1719# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1721# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
1722# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
1723# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
1724# define JSON_HEDLEY_LIKELY(expr) (!!(expr))
1725# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
1727#if !defined(JSON_HEDLEY_UNPREDICTABLE)
1728 #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
1731#if defined(JSON_HEDLEY_MALLOC)
1732 #undef JSON_HEDLEY_MALLOC
1735 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \
1736 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1737 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1738 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1739 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1740 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1741 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1742 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1743 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1744 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1745 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1746 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1747 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1748 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1749 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1750 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1751 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1752 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1753 #define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
1754#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1755 #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
1757 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1758 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1759 #define JSON_HEDLEY_MALLOC __declspec(restrict)
1761 #define JSON_HEDLEY_MALLOC
1764#if defined(JSON_HEDLEY_PURE)
1765 #undef JSON_HEDLEY_PURE
1768 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
1769 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
1770 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1771 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1772 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1773 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1774 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1775 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1776 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1777 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1778 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1779 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1780 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1781 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1782 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1783 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1784 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1785 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1786 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1787# define JSON_HEDLEY_PURE __attribute__((__pure__))
1788#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1789# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
1790#elif defined(__cplusplus) && \
1792 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1793 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
1794 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
1796# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
1798# define JSON_HEDLEY_PURE
1801#if defined(JSON_HEDLEY_CONST)
1802 #undef JSON_HEDLEY_CONST
1805 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \
1806 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \
1807 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1808 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1809 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1810 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1811 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1812 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1813 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1814 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1815 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1816 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1817 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1818 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1819 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1820 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1821 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1822 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1823 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1824 #define JSON_HEDLEY_CONST __attribute__((__const__))
1826 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1827 #define JSON_HEDLEY_CONST _Pragma("no_side_effect")
1829 #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
1832#if defined(JSON_HEDLEY_RESTRICT)
1833 #undef JSON_HEDLEY_RESTRICT
1835#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
1836 #define JSON_HEDLEY_RESTRICT restrict
1838 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1839 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1840 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1841 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1842 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1843 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1844 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1845 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1846 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
1847 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1848 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1849 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
1850 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1851 defined(__clang__) || \
1852 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1853 #define JSON_HEDLEY_RESTRICT __restrict
1854#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
1855 #define JSON_HEDLEY_RESTRICT _Restrict
1857 #define JSON_HEDLEY_RESTRICT
1860#if defined(JSON_HEDLEY_INLINE)
1861 #undef JSON_HEDLEY_INLINE
1864 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1865 (defined(__cplusplus) && (__cplusplus >= 199711L))
1866 #define JSON_HEDLEY_INLINE inline
1868 defined(JSON_HEDLEY_GCC_VERSION) || \
1869 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0)
1870 #define JSON_HEDLEY_INLINE __inline__
1872 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1873 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1874 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1875 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
1876 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1877 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1878 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1879 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1880 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1881 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1882 #define JSON_HEDLEY_INLINE __inline
1884 #define JSON_HEDLEY_INLINE
1887#if defined(JSON_HEDLEY_ALWAYS_INLINE)
1888 #undef JSON_HEDLEY_ALWAYS_INLINE
1891 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
1892 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1893 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1894 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1895 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1896 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1897 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1898 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1899 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1900 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1901 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1902 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1903 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1904 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1905 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1906 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1907 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1908 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1909 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1910# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
1912 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1913 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1914# define JSON_HEDLEY_ALWAYS_INLINE __forceinline
1915#elif defined(__cplusplus) && \
1917 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1918 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1919 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1920 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1921 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1922 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
1924# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
1925#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1926# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
1928# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
1931#if defined(JSON_HEDLEY_NEVER_INLINE)
1932 #undef JSON_HEDLEY_NEVER_INLINE
1935 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \
1936 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1937 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1938 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1939 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1940 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1941 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1942 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1943 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1944 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1945 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1946 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1947 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1948 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1949 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1950 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1951 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1952 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1953 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1954 #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
1956 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1957 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1958 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1959#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
1960 #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
1961#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1962 #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
1963#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1964 #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
1965#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1966 #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
1967#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1968 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1970 #define JSON_HEDLEY_NEVER_INLINE
1973#if defined(JSON_HEDLEY_PRIVATE)
1974 #undef JSON_HEDLEY_PRIVATE
1976#if defined(JSON_HEDLEY_PUBLIC)
1977 #undef JSON_HEDLEY_PUBLIC
1979#if defined(JSON_HEDLEY_IMPORT)
1980 #undef JSON_HEDLEY_IMPORT
1982#if defined(_WIN32) || defined(__CYGWIN__)
1983# define JSON_HEDLEY_PRIVATE
1984# define JSON_HEDLEY_PUBLIC __declspec(dllexport)
1985# define JSON_HEDLEY_IMPORT __declspec(dllimport)
1988 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
1989 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1990 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1991 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1992 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1993 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1995 defined(__TI_EABI__) && \
1997 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1998 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
2001 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2002# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
2003# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
2005# define JSON_HEDLEY_PRIVATE
2006# define JSON_HEDLEY_PUBLIC
2008# define JSON_HEDLEY_IMPORT extern
2011#if defined(JSON_HEDLEY_NO_THROW)
2012 #undef JSON_HEDLEY_NO_THROW
2015 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
2016 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
2017 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2018 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2019 #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
2021 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
2022 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
2023 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
2024 #define JSON_HEDLEY_NO_THROW __declspec(nothrow)
2026 #define JSON_HEDLEY_NO_THROW
2029#if defined(JSON_HEDLEY_FALL_THROUGH)
2030 #undef JSON_HEDLEY_FALL_THROUGH
2033 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
2034 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \
2035 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2036 #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
2037#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
2038 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
2039#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
2040 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
2041#elif defined(__fallthrough)
2042 #define JSON_HEDLEY_FALL_THROUGH __fallthrough
2044 #define JSON_HEDLEY_FALL_THROUGH
2047#if defined(JSON_HEDLEY_RETURNS_NON_NULL)
2048 #undef JSON_HEDLEY_RETURNS_NON_NULL
2051 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
2052 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2053 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2054 #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
2055#elif defined(_Ret_notnull_)
2056 #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
2058 #define JSON_HEDLEY_RETURNS_NON_NULL
2061#if defined(JSON_HEDLEY_ARRAY_PARAM)
2062 #undef JSON_HEDLEY_ARRAY_PARAM
2065 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
2066 !defined(__STDC_NO_VLA__) && \
2067 !defined(__cplusplus) && \
2068 !defined(JSON_HEDLEY_PGI_VERSION) && \
2069 !defined(JSON_HEDLEY_TINYC_VERSION)
2070 #define JSON_HEDLEY_ARRAY_PARAM(name) (name)
2072 #define JSON_HEDLEY_ARRAY_PARAM(name)
2075#if defined(JSON_HEDLEY_IS_CONSTANT)
2076 #undef JSON_HEDLEY_IS_CONSTANT
2078#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
2079 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
2083#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2084 #undef JSON_HEDLEY_IS_CONSTEXPR_
2087 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
2088 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2089 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2090 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
2091 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
2092 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2093 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
2094 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
2095 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2096 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2097 #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
2099#if !defined(__cplusplus)
2101 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
2102 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2103 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2104 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2105 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2106 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
2107 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24)
2108#if defined(__INTPTR_TYPE__)
2109 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*)
2112 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
2116 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
2117 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \
2118 !defined(JSON_HEDLEY_PGI_VERSION) && \
2119 !defined(JSON_HEDLEY_IAR_VERSION)) || \
2120 (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
2121 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2122 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
2123 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
2124 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0)
2125#if defined(__INTPTR_TYPE__)
2126 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)
2129 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0)
2132 defined(JSON_HEDLEY_GCC_VERSION) || \
2133 defined(JSON_HEDLEY_INTEL_VERSION) || \
2134 defined(JSON_HEDLEY_TINYC_VERSION) || \
2135 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
2136 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
2137 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
2138 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
2139 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
2140 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
2142# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
2146 ((void*) ((expr) * 0L) ) : \
2147((struct { char v[sizeof(void) * 2]; } *) 1) \
2153#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2154 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2155 #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
2157 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
2159 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2160 #define JSON_HEDLEY_IS_CONSTANT(expr) (0)
2162 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
2165#if defined(JSON_HEDLEY_BEGIN_C_DECLS)
2166 #undef JSON_HEDLEY_BEGIN_C_DECLS
2168#if defined(JSON_HEDLEY_END_C_DECLS)
2169 #undef JSON_HEDLEY_END_C_DECLS
2171#if defined(JSON_HEDLEY_C_DECL)
2172 #undef JSON_HEDLEY_C_DECL
2174#if defined(__cplusplus)
2175 #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
2176 #define JSON_HEDLEY_END_C_DECLS }
2177 #define JSON_HEDLEY_C_DECL extern "C"
2179 #define JSON_HEDLEY_BEGIN_C_DECLS
2180 #define JSON_HEDLEY_END_C_DECLS
2181 #define JSON_HEDLEY_C_DECL
2184#if defined(JSON_HEDLEY_STATIC_ASSERT)
2185 #undef JSON_HEDLEY_STATIC_ASSERT
2188 !defined(__cplusplus) && ( \
2189 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
2190 (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
2191 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
2192 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2193 defined(_Static_assert) \
2195# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
2197 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
2198 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
2199 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2200# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
2202# define JSON_HEDLEY_STATIC_ASSERT(expr, message)
2205#if defined(JSON_HEDLEY_NULL)
2206 #undef JSON_HEDLEY_NULL
2208#if defined(__cplusplus)
2209 #if __cplusplus >= 201103L
2210 #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
2212 #define JSON_HEDLEY_NULL NULL
2214 #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
2217 #define JSON_HEDLEY_NULL NULL
2219 #define JSON_HEDLEY_NULL ((void*) 0)
2222#if defined(JSON_HEDLEY_MESSAGE)
2223 #undef JSON_HEDLEY_MESSAGE
2225#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2226# define JSON_HEDLEY_MESSAGE(msg) \
2227 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2228 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2229 JSON_HEDLEY_PRAGMA(message msg) \
2230 JSON_HEDLEY_DIAGNOSTIC_POP
2232 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \
2233 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2234# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
2235#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
2236# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
2237#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
2238# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2239#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
2240# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2242# define JSON_HEDLEY_MESSAGE(msg)
2245#if defined(JSON_HEDLEY_WARNING)
2246 #undef JSON_HEDLEY_WARNING
2248#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2249# define JSON_HEDLEY_WARNING(msg) \
2250 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2251 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2252 JSON_HEDLEY_PRAGMA(clang warning msg) \
2253 JSON_HEDLEY_DIAGNOSTIC_POP
2255 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
2256 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
2257 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2258# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
2260 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
2261 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2262# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
2264# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
2267#if defined(JSON_HEDLEY_REQUIRE)
2268 #undef JSON_HEDLEY_REQUIRE
2270#if defined(JSON_HEDLEY_REQUIRE_MSG)
2271 #undef JSON_HEDLEY_REQUIRE_MSG
2273#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
2274# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
2275# define JSON_HEDLEY_REQUIRE(expr) \
2276 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2277 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2278 __attribute__((diagnose_if(!(expr), #expr, "error"))) \
2279 JSON_HEDLEY_DIAGNOSTIC_POP
2280# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \
2281 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2282 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2283 __attribute__((diagnose_if(!(expr), msg, "error"))) \
2284 JSON_HEDLEY_DIAGNOSTIC_POP
2286# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
2287# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error")))
2290# define JSON_HEDLEY_REQUIRE(expr)
2291# define JSON_HEDLEY_REQUIRE_MSG(expr,msg)
2294#if defined(JSON_HEDLEY_FLAGS)
2295 #undef JSON_HEDLEY_FLAGS
2297#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
2298 #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
2300 #define JSON_HEDLEY_FLAGS
2303#if defined(JSON_HEDLEY_FLAGS_CAST)
2304 #undef JSON_HEDLEY_FLAGS_CAST
2306#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0)
2307# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \
2308 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2309 _Pragma("warning(disable:188)") \
2311 JSON_HEDLEY_DIAGNOSTIC_POP \
2314# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
2317#if defined(JSON_HEDLEY_EMPTY_BASES)
2318 #undef JSON_HEDLEY_EMPTY_BASES
2321 (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \
2322 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2323 #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
2325 #define JSON_HEDLEY_EMPTY_BASES
2330#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
2331 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
2333#if defined(__clang__)
2334 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0)
2336 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
2339#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
2340 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
2342#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
2344#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
2345 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
2347#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
2349#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
2350 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
2352#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
2354#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
2355 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
2357#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
2359#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
2360 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
2362#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
2364#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
2365 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
2367#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
2369#if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
2370 #undef JSON_HEDLEY_CLANG_HAS_WARNING
2372#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
2384#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2385 #if defined(__clang__)
2386 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2387 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2389 #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2390 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2391 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2398#if !defined(JSON_HAS_CPP_26) && !defined(JSON_HAS_CPP_23) && !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
2399 #if (defined(__cplusplus) && __cplusplus > 202302L) || (defined(_MSVC_LANG) && _MSVC_LANG > 202302L)
2400 #define JSON_HAS_CPP_26
2401 #define JSON_HAS_CPP_23
2402 #define JSON_HAS_CPP_20
2403 #define JSON_HAS_CPP_17
2404 #define JSON_HAS_CPP_14
2405 #elif (defined(__cplusplus) && __cplusplus > 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG > 202002L)
2406 #define JSON_HAS_CPP_23
2407 #define JSON_HAS_CPP_20
2408 #define JSON_HAS_CPP_17
2409 #define JSON_HAS_CPP_14
2410 #elif (defined(__cplusplus) && __cplusplus > 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG > 201703L)
2411 #define JSON_HAS_CPP_20
2412 #define JSON_HAS_CPP_17
2413 #define JSON_HAS_CPP_14
2414 #elif (defined(__cplusplus) && __cplusplus > 201402L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1)
2415 #define JSON_HAS_CPP_17
2416 #define JSON_HAS_CPP_14
2417 #elif (defined(__cplusplus) && __cplusplus > 201103L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2418 #define JSON_HAS_CPP_14
2421 #define JSON_HAS_CPP_11
2425 #if __has_include(<version>)
2430#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM)
2431 #ifdef JSON_HAS_CPP_17
2432 #if defined(__cpp_lib_filesystem)
2433 #define JSON_HAS_FILESYSTEM 1
2434 #elif defined(__cpp_lib_experimental_filesystem)
2435 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2436 #elif !defined(__has_include)
2437 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2438 #elif __has_include(<filesystem>)
2439 #define JSON_HAS_FILESYSTEM 1
2440 #elif __has_include(<experimental/filesystem>)
2441 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2445 #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8
2446 #undef JSON_HAS_FILESYSTEM
2447 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2451 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8
2452 #undef JSON_HAS_FILESYSTEM
2453 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2457 #if defined(__clang_major__) && __clang_major__ < 7
2458 #undef JSON_HAS_FILESYSTEM
2459 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2463 #if defined(_MSC_VER) && _MSC_VER < 1914
2464 #undef JSON_HAS_FILESYSTEM
2465 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2469 #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
2470 #undef JSON_HAS_FILESYSTEM
2471 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2475 #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
2476 #undef JSON_HAS_FILESYSTEM
2477 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2482#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2483 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0
2486#ifndef JSON_HAS_FILESYSTEM
2487 #define JSON_HAS_FILESYSTEM 0
2490#ifndef JSON_HAS_THREE_WAY_COMPARISON
2491 #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \
2492 && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L
2493 #define JSON_HAS_THREE_WAY_COMPARISON 1
2495 #define JSON_HAS_THREE_WAY_COMPARISON 0
2499#ifndef JSON_HAS_RANGES
2501 #if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427
2502 #define JSON_HAS_RANGES 0
2503 #elif defined(__cpp_lib_ranges)
2504 #define JSON_HAS_RANGES 1
2506 #define JSON_HAS_RANGES 0
2510#ifndef JSON_HAS_STATIC_RTTI
2511 #if !defined(_HAS_STATIC_RTTI) || _HAS_STATIC_RTTI != 0
2512 #define JSON_HAS_STATIC_RTTI 1
2514 #define JSON_HAS_STATIC_RTTI 0
2518#ifdef JSON_HAS_CPP_17
2519 #define JSON_INLINE_VARIABLE inline
2521 #define JSON_INLINE_VARIABLE
2524#if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address)
2525 #define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]]
2527 #define JSON_NO_UNIQUE_ADDRESS
2531#if defined(__clang__)
2532 #pragma clang diagnostic push
2533 #pragma clang diagnostic ignored "-Wdocumentation"
2534 #pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
2538#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2539 #define JSON_THROW(exception) throw exception
2540 #define JSON_TRY try
2541 #define JSON_CATCH(exception) catch(exception)
2542 #define JSON_INTERNAL_CATCH(exception) catch(exception)
2545 #define JSON_THROW(exception) std::abort()
2546 #define JSON_TRY if(true)
2547 #define JSON_CATCH(exception) if(false)
2548 #define JSON_INTERNAL_CATCH(exception) if(false)
2552#if defined(JSON_THROW_USER)
2554 #define JSON_THROW JSON_THROW_USER
2556#if defined(JSON_TRY_USER)
2558 #define JSON_TRY JSON_TRY_USER
2560#if defined(JSON_CATCH_USER)
2562 #define JSON_CATCH JSON_CATCH_USER
2563 #undef JSON_INTERNAL_CATCH
2564 #define JSON_INTERNAL_CATCH JSON_CATCH_USER
2566#if defined(JSON_INTERNAL_CATCH_USER)
2567 #undef JSON_INTERNAL_CATCH
2568 #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2572#if !defined(JSON_ASSERT)
2574 #define JSON_ASSERT(x) assert(x)
2578#if defined(JSON_TESTS_PRIVATE)
2579 #define JSON_PRIVATE_UNLESS_TESTED public
2581 #define JSON_PRIVATE_UNLESS_TESTED private
2589#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2590 template<typename BasicJsonType> \
2591 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2594 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2596 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2597 auto it = std::find_if(std::begin(m), std::end(m), \
2598 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2600 return ej_pair.first == e; \
2602 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2604 template<typename BasicJsonType> \
2605 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2608 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2610 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2611 auto it = std::find_if(std::begin(m), std::end(m), \
2612 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2614 return ej_pair.second == j; \
2616 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2622#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2623 template<template<typename, typename, typename...> class ObjectType, \
2624 template<typename, typename...> class ArrayType, \
2625 class StringType, class BooleanType, class NumberIntegerType, \
2626 class NumberUnsignedType, class NumberFloatType, \
2627 template<typename> class AllocatorType, \
2628 template<typename, typename = void> class JSONSerializer, \
2630 class CustomBaseClass>
2632#define NLOHMANN_BASIC_JSON_TPL \
2633 basic_json<ObjectType, ArrayType, StringType, BooleanType, \
2634 NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2635 AllocatorType, JSONSerializer, BinaryType, CustomBaseClass>
2639#define NLOHMANN_JSON_EXPAND( x ) x
2640#define NLOHMANN_JSON_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME,...) NAME
2641#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
2642 NLOHMANN_JSON_PASTE64, \
2643 NLOHMANN_JSON_PASTE63, \
2644 NLOHMANN_JSON_PASTE62, \
2645 NLOHMANN_JSON_PASTE61, \
2646 NLOHMANN_JSON_PASTE60, \
2647 NLOHMANN_JSON_PASTE59, \
2648 NLOHMANN_JSON_PASTE58, \
2649 NLOHMANN_JSON_PASTE57, \
2650 NLOHMANN_JSON_PASTE56, \
2651 NLOHMANN_JSON_PASTE55, \
2652 NLOHMANN_JSON_PASTE54, \
2653 NLOHMANN_JSON_PASTE53, \
2654 NLOHMANN_JSON_PASTE52, \
2655 NLOHMANN_JSON_PASTE51, \
2656 NLOHMANN_JSON_PASTE50, \
2657 NLOHMANN_JSON_PASTE49, \
2658 NLOHMANN_JSON_PASTE48, \
2659 NLOHMANN_JSON_PASTE47, \
2660 NLOHMANN_JSON_PASTE46, \
2661 NLOHMANN_JSON_PASTE45, \
2662 NLOHMANN_JSON_PASTE44, \
2663 NLOHMANN_JSON_PASTE43, \
2664 NLOHMANN_JSON_PASTE42, \
2665 NLOHMANN_JSON_PASTE41, \
2666 NLOHMANN_JSON_PASTE40, \
2667 NLOHMANN_JSON_PASTE39, \
2668 NLOHMANN_JSON_PASTE38, \
2669 NLOHMANN_JSON_PASTE37, \
2670 NLOHMANN_JSON_PASTE36, \
2671 NLOHMANN_JSON_PASTE35, \
2672 NLOHMANN_JSON_PASTE34, \
2673 NLOHMANN_JSON_PASTE33, \
2674 NLOHMANN_JSON_PASTE32, \
2675 NLOHMANN_JSON_PASTE31, \
2676 NLOHMANN_JSON_PASTE30, \
2677 NLOHMANN_JSON_PASTE29, \
2678 NLOHMANN_JSON_PASTE28, \
2679 NLOHMANN_JSON_PASTE27, \
2680 NLOHMANN_JSON_PASTE26, \
2681 NLOHMANN_JSON_PASTE25, \
2682 NLOHMANN_JSON_PASTE24, \
2683 NLOHMANN_JSON_PASTE23, \
2684 NLOHMANN_JSON_PASTE22, \
2685 NLOHMANN_JSON_PASTE21, \
2686 NLOHMANN_JSON_PASTE20, \
2687 NLOHMANN_JSON_PASTE19, \
2688 NLOHMANN_JSON_PASTE18, \
2689 NLOHMANN_JSON_PASTE17, \
2690 NLOHMANN_JSON_PASTE16, \
2691 NLOHMANN_JSON_PASTE15, \
2692 NLOHMANN_JSON_PASTE14, \
2693 NLOHMANN_JSON_PASTE13, \
2694 NLOHMANN_JSON_PASTE12, \
2695 NLOHMANN_JSON_PASTE11, \
2696 NLOHMANN_JSON_PASTE10, \
2697 NLOHMANN_JSON_PASTE9, \
2698 NLOHMANN_JSON_PASTE8, \
2699 NLOHMANN_JSON_PASTE7, \
2700 NLOHMANN_JSON_PASTE6, \
2701 NLOHMANN_JSON_PASTE5, \
2702 NLOHMANN_JSON_PASTE4, \
2703 NLOHMANN_JSON_PASTE3, \
2704 NLOHMANN_JSON_PASTE2, \
2705 NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2706#define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2707#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2708#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2709#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2710#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2711#define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6)
2712#define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7)
2713#define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8)
2714#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9)
2715#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10)
2716#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11)
2717#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12)
2718#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13)
2719#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14)
2720#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15)
2721#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16)
2722#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17)
2723#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18)
2724#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19)
2725#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20)
2726#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21)
2727#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22)
2728#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23)
2729#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24)
2730#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25)
2731#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26)
2732#define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27)
2733#define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28)
2734#define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29)
2735#define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30)
2736#define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31)
2737#define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32)
2738#define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33)
2739#define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34)
2740#define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35)
2741#define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36)
2742#define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37)
2743#define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38)
2744#define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39)
2745#define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40)
2746#define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41)
2747#define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42)
2748#define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43)
2749#define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44)
2750#define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45)
2751#define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46)
2752#define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47)
2753#define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48)
2754#define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49)
2755#define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50)
2756#define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51)
2757#define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52)
2758#define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53)
2759#define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54)
2760#define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55)
2761#define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56)
2762#define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57)
2763#define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58)
2764#define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59)
2765#define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60)
2766#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61)
2767#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62)
2768#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63)
2770#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2771#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2772#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = !nlohmann_json_j.is_null() ? nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1) : nlohmann_json_default_obj.v1;
2780#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2781 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2782 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2783 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2784 friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2792#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2793 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2794 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2795 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2796 friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2804#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
2805 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2806 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2814#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2815 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2816 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2817 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2818 void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2826#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2827 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2828 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2829 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2830 void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2838#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
2839 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2840 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2848#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE(Type, BaseType, ...) \
2849 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2850 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2851 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2852 friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2860#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \
2861 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2862 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2863 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2864 friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2872#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, BaseType, ...) \
2873 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2874 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2882#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE(Type, BaseType, ...) \
2883 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2884 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2885 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2886 void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2894#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \
2895 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2896 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2897 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2898 void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2906#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, BaseType, ...) \
2907 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2908 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2916#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \
2917 namespace detail { \
2918 using std::std_name; \
2920 template<typename... T> \
2921 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2924 namespace detail2 { \
2925 struct std_name##_tag \
2929 template<typename... T> \
2930 std_name##_tag std_name(T&&...); \
2932 template<typename... T> \
2933 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2935 template<typename... T> \
2936 struct would_call_std_##std_name \
2938 static constexpr auto const value = ::nlohmann::detail:: \
2939 is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
2943 template<typename... T> \
2944 struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \
2948#ifndef JSON_USE_IMPLICIT_CONVERSIONS
2949 #define JSON_USE_IMPLICIT_CONVERSIONS 1
2952#if JSON_USE_IMPLICIT_CONVERSIONS
2953 #define JSON_EXPLICIT
2955 #define JSON_EXPLICIT explicit
2958#ifndef JSON_DISABLE_ENUM_SERIALIZATION
2959 #define JSON_DISABLE_ENUM_SERIALIZATION 0
2962#ifndef JSON_USE_GLOBAL_UDLS
2963 #define JSON_USE_GLOBAL_UDLS 1
2966#if JSON_HAS_THREE_WAY_COMPARISON
3029#if JSON_HAS_THREE_WAY_COMPARISON
3030 inline std::partial_ordering operator<=>(
const value_t lhs,
const value_t rhs)
noexcept
3035 static constexpr std::array<std::uint8_t, 9> order = {{
3042 const auto l_index =
static_cast<std::size_t
>(lhs);
3043 const auto r_index =
static_cast<std::size_t
>(rhs);
3044#if JSON_HAS_THREE_WAY_COMPARISON
3045 if (l_index < order.size() && r_index < order.size())
3047 return order[l_index] <=> order[r_index];
3049 return std::partial_ordering::unordered;
3051 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
3059#if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__)
3062 return std::is_lt(lhs <=> rhs);
3100template<
typename StringType>
3102 const StringType& t)
3105 for (
auto pos = s.find(f);
3106 pos != StringType::npos;
3107 s.replace(pos, f.size(), t),
3108 pos = s.find(f, pos + t.size()))
3119template<
typename StringType>
3134template<
typename StringType>
3175 constexpr operator size_t()
const
3200#include <type_traits>
3211using uncvref_t =
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
3213#ifdef JSON_HAS_CPP_14
3216using std::enable_if_t;
3217using std::index_sequence;
3218using std::make_index_sequence;
3219using std::index_sequence_for;
3224template<
bool B,
typename T =
void>
3251template <
typename T, T... Ints>
3255 static constexpr std::size_t
size() noexcept
3257 return sizeof...(Ints);
3266template <
size_t... Ints>
3272template <
typename Seq,
size_t SeqSize,
size_t Rem>
3276template <
typename T, T... Ints,
size_t SeqSize>
3282template <
typename T, T... Ints,
size_t SeqSize>
3290template <
typename T,
size_t N>
3297template <
typename T>
3312template <
typename T, T N>
3328template <
typename... Ts>
3346#ifndef JSON_HAS_CPP_17
3347 template<
typename T>
3351template<
typename T,
typename... Args>
3352constexpr std::array<T,
sizeof...(Args)>
make_array(Args&& ... args)
3354 return std::array<T,
sizeof...(Args)> {{
static_cast<T
>(std::forward<Args>(args))...}};
3374#include <type_traits>
3376#if defined(__cpp_lib_byte) && __cpp_lib_byte >= 201603L
3403template<
typename It,
typename =
void>
3406template<
typename It>
3410 typename It::reference, typename It::iterator_category >>
3421template<
typename T,
typename =
void>
3500#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3501 #define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3526 template<
typename T =
void,
typename SFINAE =
void>
3531 template<
template<
typename U,
typename V,
typename... Args>
class ObjectType =
3533 template<
typename U,
typename... Args>
class ArrayType = std::vector,
3534 class StringType = std::string,
class BooleanType = bool,
3535 class NumberIntegerType = std::int64_t,
3536 class NumberUnsignedType = std::uint64_t,
3537 class NumberFloatType = double,
3538 template<
typename U>
class AllocatorType = std::allocator,
3539 template<
typename T,
typename SFINAE =
void>
class JSONSerializer =
3541 class BinaryType = std::vector<std::uint8_t>,
3542 class CustomBaseClass =
void>
3547 template<
typename RefStringType>
3558 template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3603template<
typename BasicJsonContext>
3605 std::integral_constant < bool,
3606 is_basic_json<typename std::remove_cv<typename std::remove_pointer<BasicJsonContext>::type>::type>::value
3607 || std::is_same<BasicJsonContext, std::nullptr_t>::value >
3648template<
typename T,
typename... Args>
3651template<
typename T,
typename... Args>
3654template<
typename T,
typename U>
3658template<
typename BasicJsonType,
typename T,
typename =
void>
3665template <
typename BasicJsonType,
typename T>
3671template<
typename BasicJsonType,
typename T>
3674 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3678 const BasicJsonType&, T&>
::value;
3683template<
typename BasicJsonType,
typename T,
typename =
void>
3686template<
typename BasicJsonType,
typename T>
3689 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3698template<
typename BasicJsonType,
typename T,
typename =
void>
3701template<
typename BasicJsonType,
typename T>
3704 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3715struct has_key_compare : std::integral_constant<bool, is_detected<detect_key_compare, T>::value> {};
3718template<
typename BasicJsonType>
3723 using type =
typename std::conditional < has_key_compare<object_t>::value,
3727template<
typename BasicJsonType>
3759 return static_cast<int_type>(std::char_traits<char>::eof());
3783 return static_cast<int_type>(std::char_traits<char>::eof());
3787#if defined(__cpp_lib_byte) && __cpp_lib_byte >= 201603L
3789struct char_traits<
std::byte> : std::char_traits<char>
3791 using char_type = std::byte;
3792 using int_type = uint64_t;
3794 static int_type to_int_type(char_type c)
noexcept
3796 return static_cast<int_type
>(std::to_integer<unsigned char>(c));
3799 static char_type to_char_type(int_type i)
noexcept
3801 return std::byte(
static_cast<unsigned char>(i));
3804 static constexpr int_type eof() noexcept
3806 return static_cast<int_type
>(std::char_traits<char>::eof());
3818template<
class B,
class... Bn>
3820: std::conditional<static_cast<bool>(B::value), conjunction<Bn...>, B>::type {};
3823template<
class B>
struct negation : std::integral_constant < bool, !B::value > { };
3828template <
typename T>
3831template <
typename T1,
typename T2>
3833 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3835template <
typename T1,
typename T2>
3837 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3839template <
typename... Ts>
3841 :
conjunction<is_default_constructible<Ts>...> {};
3843template <
typename... Ts>
3845 :
conjunction<is_default_constructible<Ts>...> {};
3847template <
typename T,
typename... Args>
3850template <
typename T1,
typename T2>
3853template <
typename T1,
typename T2>
3856template <
typename... Ts>
3859template <
typename... Ts>
3862template<
typename T,
typename =
void>
3884 using t_ref =
typename std::add_lvalue_reference<T>::type;
3892 static constexpr auto is_iterator_begin =
3896 static constexpr bool value = !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value && is_iterator_begin;
3909template<
typename T,
typename =
void>
3915template<
typename BasicJsonType,
typename CompatibleObjectType,
3919template<
typename BasicJsonType,
typename CompatibleObjectType>
3921 BasicJsonType, CompatibleObjectType,
3930 typename CompatibleObjectType::key_type>
::value &&
3932 typename CompatibleObjectType::mapped_type>
::value;
3935template<
typename BasicJsonType,
typename CompatibleObjectType>
3939template<
typename BasicJsonType,
typename ConstructibleObjectType,
3943template<
typename BasicJsonType,
typename ConstructibleObjectType>
3945 BasicJsonType, ConstructibleObjectType,
3953 (std::is_move_assignable<ConstructibleObjectType>::value ||
3954 std::is_copy_assignable<ConstructibleObjectType>::value) &&
3956 typename object_t::key_type>
::value &&
3958 typename object_t::mapped_type,
3959 typename ConstructibleObjectType::mapped_type >
::value)) ||
3961 typename ConstructibleObjectType::mapped_type>
::value ||
3964 typename ConstructibleObjectType::mapped_type >
::value);
3967template<
typename BasicJsonType,
typename ConstructibleObjectType>
3970 ConstructibleObjectType> {};
3972template<
typename BasicJsonType,
typename CompatibleStringType>
3979template<
typename BasicJsonType,
typename ConstructibleStringType>
3983#ifdef __INTEL_COMPILER
3984 using laundered_type =
decltype(std::declval<ConstructibleStringType>());
3996template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
3999template<
typename BasicJsonType,
typename CompatibleArrayType>
4001 BasicJsonType, CompatibleArrayType,
4007 !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>
::value >>
4014template<
typename BasicJsonType,
typename CompatibleArrayType>
4018template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
4021template<
typename BasicJsonType,
typename ConstructibleArrayType>
4023 BasicJsonType, ConstructibleArrayType,
4025 typename BasicJsonType::value_type>
::value >>
4026 : std::true_type {};
4028template<
typename BasicJsonType,
typename ConstructibleArrayType>
4030 BasicJsonType, ConstructibleArrayType,
4032 typename BasicJsonType::value_type>
::value&&
4035(std::is_move_assignable<ConstructibleArrayType>::value ||
4036 std::is_copy_assignable<ConstructibleArrayType>::value)&&
4042!std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>
::value&&
4044detected_t<range_value_t, ConstructibleArrayType >>
::value >>
4050 typename BasicJsonType::array_t::value_type>
::value ||
4058template<
typename BasicJsonType,
typename ConstructibleArrayType>
4062template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
4066template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
4068 RealIntegerType, CompatibleNumberIntegerType,
4070 std::is_integral<CompatibleNumberIntegerType>
::value&&
4071 !std::is_same<bool, CompatibleNumberIntegerType>
::value >>
4079 CompatibleNumberIntegerType>
::value &&
4080 CompatibleLimits::is_integer &&
4081 RealLimits::is_signed == CompatibleLimits::is_signed;
4084template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
4087 CompatibleNumberIntegerType> {};
4089template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
4092template<
typename BasicJsonType,
typename CompatibleType>
4094 BasicJsonType, CompatibleType,
4101template<
typename BasicJsonType,
typename CompatibleType>
4105template<
typename T1,
typename T2>
4108template<
typename T1,
typename... Args>
4111template<
typename BasicJsonType,
typename T>
4114template<
typename BasicJsonType>
4117template<
typename BasicJsonType>
4122template<
template <
typename...>
class Primary,
typename T>
4125template<
template <
typename...>
class Primary,
typename... Args>
4132template<
typename Compare,
typename A,
typename B,
typename =
void>
4135template<
typename Compare,
typename A,
typename B>
4137decltype(
std::declval<Compare>()(std::declval<A>(), std::declval<B>())),
4138decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))
4139>> : std::true_type {};
4146template<
typename Comparator,
typename ObjectKeyType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
4150 && !(ExcludeObjectKeyType && std::is_same<KeyType,
4152 && (!RequireTransparentComparator
4153 || is_detected <detect_is_transparent, Comparator>::value)
4156 std::false_type >::type;
4164template<
typename BasicJsonType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
4168 typename BasicJsonType::object_t::key_type, KeyTypeCVRef,
4169 RequireTransparentComparator, ExcludeObjectKeyType>
::value
4172 std::false_type >::type;
4174template<
typename ObjectType,
typename KeyType>
4178template<
typename BasicJsonType,
typename KeyType>
4182 typename BasicJsonType::object_t, KeyType >
::value,
4184 std::false_type >::type;
4188template <
typename T>
4198 template <
typename C>
static one test(
decltype(&C::capacity) ) ;
4205template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value,
int > = 0 >
4208 return static_cast<T
>(
value);
4211template<typename T, typename U, enable_if_t<std::is_same<T, U>::value,
int> = 0>
4217template<
typename... Types>
4220template<
typename... Types>
4223template<
typename... Types>
4227template<
typename... Types>
4231template<
typename OfType,
typename T>
4233 (std::is_signed<OfType>::value && (
sizeof(T) <
sizeof(OfType)))
4236template<
typename OfType,
typename T,
4237 bool OfTypeSigned = std::is_signed<OfType>::value,
4238 bool TSigned = std::is_signed<T>::value>
4241template<
typename OfType,
typename T>
4246 using CommonType =
typename std::common_type<OfType, T>::type;
4247 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4251template<
typename OfType,
typename T>
4256 using CommonType =
typename std::common_type<OfType, T>::type;
4257 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4261template<
typename OfType,
typename T>
4266 using CommonType =
typename std::common_type<OfType, T>::type;
4267 return val >= 0 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4271template<
typename OfType,
typename T>
4276 using CommonType =
typename std::common_type<OfType, T>::type;
4277 return static_cast<CommonType
>(val) >=
static_cast<CommonType
>((std::numeric_limits<OfType>::min)())
4278 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4282template<
typename OfType,
typename T,
4283 bool NeverOutOfRange = never_out_of_range<OfType, T>::value,
4287template<
typename OfType,
typename T>
4296template<
typename OfType,
typename T>
4305template<
typename OfType,
typename T>
4324 using TUnExt =
typename std::remove_extent<T>::type;
4325 using TUnCVExt =
typename std::remove_cv<TUnExt>::type;
4326 using TUnPtr =
typename std::remove_pointer<T>::type;
4327 using TUnCVPtr =
typename std::remove_cv<TUnPtr>::type;
4329 (std::is_array<T>::value && std::is_same<TUnCVExt, char>::value)
4330 || (std::is_pointer<T>::value && std::is_same<TUnCVPtr, char>::value);
4395template<
typename... Args>
4396inline std::size_t
concat_length(
const char* cstr,
const Args& ... rest);
4398template<
typename StringType,
typename... Args>
4399inline std::size_t
concat_length(
const StringType& str,
const Args& ... rest);
4401template<
typename... Args>
4407template<
typename... Args>
4414template<
typename StringType,
typename... Args>
4420template<
typename OutStringType>
4424template<
typename StringType,
typename Arg>
4427template<
typename StringType,
typename Arg>
4430template<
typename StringType,
typename Arg>
4433template<
typename StringType,
typename Arg>
4436template<
typename StringType,
typename Arg>
4437using string_can_append_iter =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().begin(), std::declval<const Arg&>().end()));
4439template<
typename StringType,
typename Arg>
4442template<
typename StringType,
typename Arg>
4443using string_can_append_data =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().data(), std::declval<const Arg&>().size()));
4445template<
typename StringType,
typename Arg>
4448template <
typename OutStringType,
typename Arg,
typename... Args,
4449 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4451inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest);
4453template <
typename OutStringType,
typename Arg,
typename... Args,
4454 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4457inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4459template <
typename OutStringType,
typename Arg,
typename... Args,
4460 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4464inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4466template<
typename OutStringType,
typename Arg,
typename... Args,
4468inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest)
4470 out.append(std::forward<Arg>(arg));
4474template <
typename OutStringType,
typename Arg,
typename... Args,
4475 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4476 && detect_string_can_append_op<OutStringType, Arg>::value,
int > >
4477inline void concat_into(OutStringType& out, Arg&& arg, Args&& ... rest)
4479 out += std::forward<Arg>(arg);
4483template <
typename OutStringType,
typename Arg,
typename... Args,
4484 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4485 && !detect_string_can_append_op<OutStringType, Arg>::value
4486 && detect_string_can_append_iter<OutStringType, Arg>::value,
int > >
4487inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4489 out.append(arg.begin(), arg.end());
4493template <
typename OutStringType,
typename Arg,
typename... Args,
4494 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4495 && !detect_string_can_append_op<OutStringType, Arg>::value
4496 && !detect_string_can_append_iter<OutStringType, Arg>::value
4497 && detect_string_can_append_data<OutStringType, Arg>::value,
int > >
4498inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4500 out.append(arg.data(), arg.size());
4504template<
typename OutStringType = std::string,
typename... Args>
4524#if defined(__clang__)
4525 #pragma clang diagnostic push
4526 #pragma clang diagnostic ignored "-Wweak-vtables"
4543 const char*
what() const noexcept
override
4553 exception(
int id_, const
char* what_arg) :
id(id_), m(what_arg) {}
4555 static std::string
name(
const std::string& ename,
int id_)
4557 return concat(
"[json.exception.", ename,
'.', std::to_string(id_),
"] ");
4565 template<
typename BasicJsonType>
4569 std::vector<std::string> tokens;
4570 for (
const auto* current = leaf_element; current !=
nullptr && current->m_parent !=
nullptr; current = current->m_parent)
4572 switch (current->m_parent->type())
4576 for (std::size_t i = 0; i < current->m_parent->m_data.m_value.array->size(); ++i)
4578 if (¤t->m_parent->m_data.m_value.array->operator[](i) == current)
4580 tokens.emplace_back(std::to_string(i));
4589 for (
const auto& element : *current->m_parent->m_data.m_value.object)
4591 if (&element.second == current)
4593 tokens.emplace_back(element.first.c_str());
4618 auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
4619 [](
const std::string & a,
const std::string & b)
4621 return concat(a,
'/', detail::escape(b));
4624 return concat(
'(', str,
") ", get_byte_positions(leaf_element));
4626 return get_byte_positions(leaf_element);
4632 std::runtime_error m;
4633#if JSON_DIAGNOSTIC_POSITIONS
4634 template<
typename BasicJsonType>
4635 static std::string get_byte_positions(
const BasicJsonType* leaf_element)
4637 if ((leaf_element->start_pos() != std::string::npos) && (leaf_element->end_pos() != std::string::npos))
4639 return concat(
"(bytes ", std::to_string(leaf_element->start_pos()),
"-", std::to_string(leaf_element->end_pos()),
") ");
4644 template<
typename BasicJsonType>
4645 static std::string get_byte_positions(
const BasicJsonType* leaf_element)
4647 static_cast<void>(leaf_element);
4667 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4668 static parse_error
create(
int id_,
const position_t& pos,
const std::string& what_arg, BasicJsonContext context)
4675 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4676 static parse_error
create(
int id_, std::size_t byte_,
const std::string& what_arg, BasicJsonContext context)
4679 (byte_ != 0 ? (
concat(
" at byte ", std::to_string(byte_))) :
""),
4681 return {id_, byte_, w.c_str()};
4696 parse_error(
int id_, std::size_t byte_,
const char* what_arg)
4699 static std::string position_string(
const position_t& pos)
4711 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4712 static invalid_iterator
create(
int id_,
const std::string& what_arg, BasicJsonContext context)
4715 return {id_, w.c_str()};
4729 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4730 static type_error
create(
int id_,
const std::string& what_arg, BasicJsonContext context)
4733 return {id_, w.c_str()};
4746 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4747 static out_of_range
create(
int id_,
const std::string& what_arg, BasicJsonContext context)
4750 return {id_, w.c_str()};
4763 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4764 static other_error
create(
int id_,
const std::string& what_arg, BasicJsonContext context)
4767 return {id_, w.c_str()};
4778#if defined(__clang__)
4779 #pragma clang diagnostic pop
4824#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
4825#include <experimental/filesystem>
4829namespace std_fs = std::experimental::filesystem;
4832#elif JSON_HAS_FILESYSTEM
4833#include <filesystem>
4837namespace std_fs = std::filesystem;
4850#ifdef JSON_HAS_CPP_17
4854#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
4855 #include <string_view>
4862template<
typename BasicJsonType>
4863inline void from_json(
const BasicJsonType& j,
typename std::nullptr_t& n)
4872#ifdef JSON_HAS_CPP_17
4873template<
typename BasicJsonType,
typename T>
4874void from_json(
const BasicJsonType& j, std::optional<T>& opt)
4882 opt.emplace(j.template
get<T>());
4888template <
typename BasicJsonType,
typename ArithmeticType,
4889 enable_if_t < std::is_arithmetic<ArithmeticType>::value&&
4890 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4894 switch (
static_cast<value_t>(j))
4898 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4903 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4908 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4924template<
typename BasicJsonType>
4925inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::boolean_t& b)
4931 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
4934template<
typename BasicJsonType>
4935inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::string_t& s)
4941 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4945 typename BasicJsonType,
typename StringType,
4947 std::is_assignable<StringType&, const typename BasicJsonType::string_t>::value
4948 && is_detected_exact<typename BasicJsonType::string_t::value_type, value_type_t, StringType>::value
4949 && !std::is_same<typename BasicJsonType::string_t, StringType>::value
4950 && !is_json_ref<StringType>::value,
int > = 0 >
4958 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4961template<
typename BasicJsonType>
4962inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_float_t& val)
4967template<
typename BasicJsonType>
4968inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_unsigned_t& val)
4973template<
typename BasicJsonType>
4974inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_integer_t& val)
4979#if !JSON_DISABLE_ENUM_SERIALIZATION
4980template<
typename BasicJsonType,
typename EnumType,
4981 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
4984 typename std::underlying_type<EnumType>::type val;
4986 e =
static_cast<EnumType
>(val);
4991template<
typename BasicJsonType,
typename T,
typename Allocator,
4992 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4993inline void from_json(
const BasicJsonType& j, std::forward_list<T, Allocator>& l)
5000 std::transform(j.rbegin(), j.rend(),
5001 std::front_inserter(l), [](
const BasicJsonType & i)
5003 return i.template get<T>();
5008template<
typename BasicJsonType,
typename T,
5009 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
5010inline void from_json(
const BasicJsonType& j, std::valarray<T>& l)
5017 std::transform(j.begin(), j.end(), std::begin(l),
5018 [](
const BasicJsonType & elem)
5020 return elem.template get<T>();
5024template<
typename BasicJsonType,
typename T, std::
size_t N>
5026->
decltype(j.template
get<T>(), void())
5028 for (std::size_t i = 0; i < N; ++i)
5030 arr[i] = j.at(i).template
get<T>();
5034template<
typename BasicJsonType,
typename T, std::
size_t N1, std::
size_t N2>
5036->
decltype(j.template
get<T>(), void())
5038 for (std::size_t i1 = 0; i1 < N1; ++i1)
5040 for (std::size_t i2 = 0; i2 < N2; ++i2)
5042 arr[i1][i2] = j.at(i1).at(i2).template
get<T>();
5047template<
typename BasicJsonType,
typename T, std::
size_t N1, std::
size_t N2, std::
size_t N3>
5049->
decltype(j.template
get<T>(), void())
5051 for (std::size_t i1 = 0; i1 < N1; ++i1)
5053 for (std::size_t i2 = 0; i2 < N2; ++i2)
5055 for (std::size_t i3 = 0; i3 < N3; ++i3)
5057 arr[i1][i2][i3] = j.at(i1).at(i2).at(i3).template
get<T>();
5063template<
typename BasicJsonType,
typename T, std::
size_t N1, std::
size_t N2, std::
size_t N3, std::
size_t N4>
5064auto from_json(
const BasicJsonType& j, T (&arr)[N1][N2][N3][N4])
5065->
decltype(j.template
get<T>(), void())
5067 for (std::size_t i1 = 0; i1 < N1; ++i1)
5069 for (std::size_t i2 = 0; i2 < N2; ++i2)
5071 for (std::size_t i3 = 0; i3 < N3; ++i3)
5073 for (std::size_t i4 = 0; i4 < N4; ++i4)
5075 arr[i1][i2][i3][i4] = j.at(i1).at(i2).at(i3).at(i4).template
get<T>();
5082template<
typename BasicJsonType>
5085 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
5088template<
typename BasicJsonType,
typename T, std::
size_t N>
5091->
decltype(j.template
get<T>(), void())
5093 for (std::size_t i = 0; i < N; ++i)
5095 arr[i] = j.at(i).template
get<T>();
5099template<
typename BasicJsonType,
typename ConstructibleArrayType,
5101 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
5105 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
5111 ConstructibleArrayType ret;
5112 ret.reserve(j.size());
5113 std::transform(j.begin(), j.end(),
5114 std::inserter(ret, end(ret)), [](
const BasicJsonType & i)
5120 arr = std::move(ret);
5123template<
typename BasicJsonType,
typename ConstructibleArrayType,
5125 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
5132 ConstructibleArrayType ret;
5134 j.begin(), j.end(), std::inserter(ret, end(ret)),
5135 [](
const BasicJsonType & i)
5141 arr = std::move(ret);
5144template <
typename BasicJsonType,
typename ConstructibleArrayType,
5146 is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value&&
5147 !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value&&
5149 !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value&&
5150 !is_basic_json<ConstructibleArrayType>::value,
5152auto from_json(
const BasicJsonType& j, ConstructibleArrayType& arr)
5165template <
typename BasicJsonType,
typename T, std::size_t... Idx >
5169 return { { std::forward<BasicJsonType>(j).at(Idx).template
get<T>()... } };
5172template <
typename BasicJsonType,
typename T, std::
size_t N >
5184template<
typename BasicJsonType>
5185inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::binary_t& bin)
5192 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
5195template<
typename BasicJsonType,
typename ConstructibleObjectType,
5196 enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value,
int> = 0>
5197inline void from_json(
const BasicJsonType& j, ConstructibleObjectType& obj)
5204 ConstructibleObjectType ret;
5205 const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
5206 using value_type =
typename ConstructibleObjectType::value_type;
5208 inner_object->begin(), inner_object->end(),
5209 std::inserter(ret, ret.begin()),
5210 [](
typename BasicJsonType::object_t::value_type
const & p)
5212 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
5214 obj = std::move(ret);
5221template <
typename BasicJsonType,
typename ArithmeticType,
5223 std::is_arithmetic<ArithmeticType>::value&&
5224 !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value&&
5225 !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value&&
5226 !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value&&
5227 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
5229inline void from_json(
const BasicJsonType& j, ArithmeticType& val)
5231 switch (
static_cast<value_t>(j))
5235 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
5240 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
5245 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
5250 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
5265template<
typename BasicJsonType,
typename... Args, std::size_t... Idx>
5268 return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).
template get<Args>()...);
5271template<
typename BasicJsonType>
5277template <
typename BasicJsonType,
class A1,
class A2 >
5280 return {std::forward<BasicJsonType>(j).at(0).template
get<A1>(),
5281 std::forward<BasicJsonType>(j).at(1).template
get<A2>()};
5284template<
typename BasicJsonType,
typename A1,
typename A2>
5290template<
typename BasicJsonType,
typename... Args>
5296template<
typename BasicJsonType,
typename... Args>
5302template<
typename BasicJsonType,
typename TupleRelated>
5314template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
5316 typename BasicJsonType::string_t, Key >
::value >>
5317inline void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
5324 for (
const auto& p : j)
5334template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
5336 typename BasicJsonType::string_t, Key >
::value >>
5337inline void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
5344 for (
const auto& p : j)
5354#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
5355template<
typename BasicJsonType>
5356inline void from_json(
const BasicJsonType& j, std_fs::path& p)
5362 const auto& s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
5366#if defined(__cpp_lib_char8_t) && (__cpp_lib_char8_t >= 201907L)
5367 p = std_fs::path(std::u8string_view(
reinterpret_cast<const char8_t*
>(s.data()), s.size()));
5369 p = std_fs::u8path(s);
5376 template<
typename BasicJsonType,
typename T>
5378 noexcept(
noexcept(
from_json(j, std::forward<T>(val))))
5379 ->
decltype(
from_json(j, std::forward<T>(val)))
5381 return from_json(j, std::forward<T>(val));
5387#ifndef JSON_HAS_CPP_17
5396#ifndef JSON_HAS_CPP_17
5415#ifdef JSON_HAS_CPP_17
5424#include <type_traits>
5474template<
typename StringType>
5478 using std::to_string;
5482template<
typename StringType>
5508 using string_type =
typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().key() ) >::type >::type;
5512 IteratorType anchor{};
5514 std::size_t array_index = 0;
5516 mutable std::size_t array_index_last = 0;
5525 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5527 : anchor(
std::move(it))
5528 , array_index(array_index_)
5535 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5538 noexcept(
std::is_nothrow_move_assignable<IteratorType>::
value
5568 return anchor == o.anchor;
5574 return anchor != o.anchor;
5582 switch (anchor.m_object->type())
5587 if (array_index != array_index_last)
5590 array_index_last = array_index;
5592 return array_index_str;
5597 return anchor.key();
5614 typename IteratorType::reference
value()
const
5616 return anchor.value();
5625 typename IteratorType::pointer container =
nullptr;
5632 : container(&cont) {}
5656template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
5657auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) ->
decltype(i.key())
5664template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
5665auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) ->
decltype(i.value())
5680#if defined(__clang__)
5682 #pragma clang diagnostic push
5683 #pragma clang diagnostic ignored "-Wmismatched-tags"
5685template<
typename IteratorType>
5686class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>>
5687 :
public std::integral_constant<std::size_t, 2> {};
5689template<std::
size_t N,
typename IteratorType>
5690class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >>
5694 get<N>(std::declval <
5695 ::nlohmann::detail::iteration_proxy_value<IteratorType >> ()));
5697#if defined(__clang__)
5698 #pragma clang diagnostic pop
5704 template <
typename IteratorType>
5705 inline constexpr bool ::std::ranges::enable_borrowed_range<::nlohmann::detail::iteration_proxy<IteratorType>> =
true;
5737 template<
typename BasicJsonType>
5738 static void construct(BasicJsonType& j,
typename BasicJsonType::boolean_t b)
noexcept
5740 j.m_data.m_value.destroy(j.m_data.m_type);
5742 j.m_data.m_value = b;
5743 j.assert_invariant();
5750 template<
typename BasicJsonType>
5751 static void construct(BasicJsonType& j,
const typename BasicJsonType::string_t& s)
5753 j.m_data.m_value.destroy(j.m_data.m_type);
5755 j.m_data.m_value = s;
5756 j.assert_invariant();
5759 template<
typename BasicJsonType>
5760 static void construct(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5762 j.m_data.m_value.destroy(j.m_data.m_type);
5764 j.m_data.m_value = std::move(s);
5765 j.assert_invariant();
5768 template <
typename BasicJsonType,
typename CompatibleStringType,
5769 enable_if_t < !std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value,
5771 static void construct(BasicJsonType& j,
const CompatibleStringType& str)
5773 j.m_data.m_value.destroy(j.m_data.m_type);
5775 j.m_data.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
5776 j.assert_invariant();
5783 template<
typename BasicJsonType>
5784 static void construct(BasicJsonType& j,
const typename BasicJsonType::binary_t& b)
5786 j.m_data.m_value.destroy(j.m_data.m_type);
5788 j.m_data.m_value =
typename BasicJsonType::binary_t(b);
5789 j.assert_invariant();
5792 template<
typename BasicJsonType>
5793 static void construct(BasicJsonType& j,
typename BasicJsonType::binary_t&& b)
5795 j.m_data.m_value.destroy(j.m_data.m_type);
5797 j.m_data.m_value =
typename BasicJsonType::binary_t(std::move(b));
5798 j.assert_invariant();
5805 template<
typename BasicJsonType>
5806 static void construct(BasicJsonType& j,
typename BasicJsonType::number_float_t val)
noexcept
5808 j.m_data.m_value.destroy(j.m_data.m_type);
5810 j.m_data.m_value = val;
5811 j.assert_invariant();
5818 template<
typename BasicJsonType>
5819 static void construct(BasicJsonType& j,
typename BasicJsonType::number_unsigned_t val)
noexcept
5821 j.m_data.m_value.destroy(j.m_data.m_type);
5823 j.m_data.m_value = val;
5824 j.assert_invariant();
5831 template<
typename BasicJsonType>
5832 static void construct(BasicJsonType& j,
typename BasicJsonType::number_integer_t val)
noexcept
5834 j.m_data.m_value.destroy(j.m_data.m_type);
5836 j.m_data.m_value = val;
5837 j.assert_invariant();
5844 template<
typename BasicJsonType>
5845 static void construct(BasicJsonType& j,
const typename BasicJsonType::array_t& arr)
5847 j.m_data.m_value.destroy(j.m_data.m_type);
5849 j.m_data.m_value = arr;
5851 j.assert_invariant();
5854 template<
typename BasicJsonType>
5855 static void construct(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5857 j.m_data.m_value.destroy(j.m_data.m_type);
5859 j.m_data.m_value = std::move(arr);
5861 j.assert_invariant();
5864 template <
typename BasicJsonType,
typename CompatibleArrayType,
5865 enable_if_t < !std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value,
5867 static void construct(BasicJsonType& j,
const CompatibleArrayType& arr)
5872 j.m_data.m_value.destroy(j.m_data.m_type);
5874 j.m_data.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
5876 j.assert_invariant();
5879 template<
typename BasicJsonType>
5880 static void construct(BasicJsonType& j,
const std::vector<bool>& arr)
5882 j.m_data.m_value.destroy(j.m_data.m_type);
5885 j.m_data.m_value.array->reserve(arr.size());
5886 for (
const bool x : arr)
5888 j.m_data.m_value.array->push_back(x);
5889 j.set_parent(j.m_data.m_value.array->back());
5891 j.assert_invariant();
5894 template<
typename BasicJsonType,
typename T,
5896 static void construct(BasicJsonType& j,
const std::valarray<T>& arr)
5898 j.m_data.m_value.destroy(j.m_data.m_type);
5901 j.m_data.m_value.array->resize(arr.size());
5904 std::copy(std::begin(arr), std::end(arr), j.m_data.m_value.array->begin());
5907 j.assert_invariant();
5914 template<
typename BasicJsonType>
5915 static void construct(BasicJsonType& j,
const typename BasicJsonType::object_t& obj)
5917 j.m_data.m_value.destroy(j.m_data.m_type);
5919 j.m_data.m_value = obj;
5921 j.assert_invariant();
5924 template<
typename BasicJsonType>
5925 static void construct(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5927 j.m_data.m_value.destroy(j.m_data.m_type);
5929 j.m_data.m_value = std::move(obj);
5931 j.assert_invariant();
5934 template <
typename BasicJsonType,
typename CompatibleObjectType,
5935 enable_if_t < !std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value,
int > = 0 >
5936 static void construct(BasicJsonType& j,
const CompatibleObjectType& obj)
5941 j.m_data.m_value.destroy(j.m_data.m_type);
5943 j.m_data.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
5945 j.assert_invariant();
5953#ifdef JSON_HAS_CPP_17
5954template<
typename BasicJsonType,
typename T,
5955 enable_if_t<std::is_constructible<BasicJsonType, T>::value,
int> = 0>
5956void to_json(BasicJsonType& j,
const std::optional<T>& opt)
noexcept
5958 if (opt.has_value())
5969template<
typename BasicJsonType,
typename T,
5971inline void to_json(BasicJsonType& j, T b)
noexcept
5976template <
typename BasicJsonType,
typename BoolRef,
5978 ((std::is_same<std::vector<bool>::reference, BoolRef>
::value
5979 && !std::is_same <std::vector<bool>::reference,
typename BasicJsonType::boolean_t&>
::value)
5980 || (std::is_same<std::vector<bool>::const_reference, BoolRef>
::value
5981 && !std::is_same <detail::uncvref_t<std::vector<bool>::const_reference>,
5982 typename BasicJsonType::boolean_t >
::value))
5983 && std::is_convertible<const BoolRef&, typename BasicJsonType::boolean_t>::value,
int > = 0 >
5984inline void to_json(BasicJsonType& j,
const BoolRef& b)
noexcept
5989template<
typename BasicJsonType,
typename CompatibleString,
5990 enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value,
int> = 0>
5991inline void to_json(BasicJsonType& j,
const CompatibleString& s)
5996template<
typename BasicJsonType>
5997inline void to_json(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
6002template<
typename BasicJsonType,
typename FloatType,
6003 enable_if_t<std::is_floating_point<FloatType>::value,
int> = 0>
6004inline void to_json(BasicJsonType& j, FloatType val)
noexcept
6009template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
6010 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value,
int> = 0>
6011inline void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val)
noexcept
6016template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
6017 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value,
int> = 0>
6018inline void to_json(BasicJsonType& j, CompatibleNumberIntegerType val)
noexcept
6023#if !JSON_DISABLE_ENUM_SERIALIZATION
6024template<
typename BasicJsonType,
typename EnumType,
6025 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
6026inline void to_json(BasicJsonType& j, EnumType e)
noexcept
6028 using underlying_type =
typename std::underlying_type<EnumType>::type;
6034template<
typename BasicJsonType>
6035inline void to_json(BasicJsonType& j,
const std::vector<bool>& e)
6040template <
typename BasicJsonType,
typename CompatibleArrayType,
6041 enable_if_t < is_compatible_array_type<BasicJsonType,
6043 !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value&&
6045 !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&&
6046 !is_basic_json<CompatibleArrayType>::value,
6048inline void to_json(BasicJsonType& j,
const CompatibleArrayType& arr)
6053template<
typename BasicJsonType>
6054inline void to_json(BasicJsonType& j,
const typename BasicJsonType::binary_t& bin)
6059template<
typename BasicJsonType,
typename T,
6060 enable_if_t<std::is_convertible<T, BasicJsonType>::value,
int> = 0>
6061inline void to_json(BasicJsonType& j,
const std::valarray<T>& arr)
6066template<
typename BasicJsonType>
6067inline void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
6072template <
typename BasicJsonType,
typename CompatibleObjectType,
6073 enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&& !is_basic_json<CompatibleObjectType>::value,
int > = 0 >
6074inline void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
6079template<
typename BasicJsonType>
6080inline void to_json(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
6086 typename BasicJsonType,
typename T, std::size_t N,
6087 enable_if_t < !std::is_constructible<
typename BasicJsonType::string_t,
6090inline void to_json(BasicJsonType& j,
const T(&arr)[N])
6095template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value,
int > = 0 >
6096inline void to_json(BasicJsonType& j,
const std::pair<T1, T2>& p)
6098 j = { p.first, p.second };
6102template<
typename BasicJsonType,
typename T,
6106 j = { {b.key(), b.value()} };
6109template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
6112 j = { std::get<Idx>(t)... };
6115template<
typename BasicJsonType,
typename Tuple>
6118 using array_t =
typename BasicJsonType::array_t;
6122template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value,
int > = 0>
6128#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
6129#if defined(__cpp_lib_char8_t)
6130template<
typename BasicJsonType,
typename Tr,
typename Allocator>
6131inline void to_json(BasicJsonType& j,
const std::basic_string<char8_t, Tr, Allocator>& s)
6133 using OtherAllocator =
typename std::allocator_traits<Allocator>::template rebind_alloc<char>;
6134 j = std::basic_string<char, std::char_traits<char>, OtherAllocator>(s.begin(), s.end(), s.get_allocator());
6138template<
typename BasicJsonType>
6139inline void to_json(BasicJsonType& j,
const std_fs::path& p)
6149 template<
typename BasicJsonType,
typename T>
6150 auto operator()(BasicJsonType& j, T&& val)
const noexcept(
noexcept(
to_json(j, std::forward<T>(val))))
6151 ->
decltype(
to_json(j, std::forward<T>(val)),
void())
6153 return to_json(j, std::forward<T>(val));
6158#ifndef JSON_HAS_CPP_17
6167#ifndef JSON_HAS_CPP_17
6179template<
typename ValueType,
typename>
6184 template<
typename BasicJsonType,
typename TargetType = ValueType>
6185 static auto from_json(BasicJsonType && j, TargetType& val)
noexcept(
6186 noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
6187 ->
decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val),
void())
6189 ::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
6194 template<
typename BasicJsonType,
typename TargetType = ValueType>
6199 return ::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {});
6204 template<
typename BasicJsonType,
typename TargetType = ValueType>
6205 static auto to_json(BasicJsonType& j, TargetType && val)
noexcept(
6206 noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))))
6207 ->
decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)),
void())
6209 ::nlohmann::to_json(j, std::forward<TargetType>(val));
6237template<
typename BinaryType>
6262 , m_subtype(subtype_)
6263 , m_has_subtype(true)
6269 , m_subtype(subtype_)
6270 , m_has_subtype(true)
6275 return std::tie(
static_cast<const BinaryType&
>(*
this), m_subtype, m_has_subtype) ==
6276 std::tie(
static_cast<const BinaryType&
>(rhs), rhs.m_subtype, rhs.m_has_subtype);
6281 return !(rhs == *
this);
6288 m_subtype = subtype_;
6289 m_has_subtype =
true;
6296 return m_has_subtype ? m_subtype :
static_cast<subtype_type>(-1);
6303 return m_has_subtype;
6311 m_has_subtype =
false;
6316 bool m_has_subtype =
false;
6340#include <functional>
6352inline std::size_t
combine(std::size_t seed, std::size_t h)
noexcept
6354 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
6369template<
typename BasicJsonType>
6370std::size_t
hash(
const BasicJsonType& j)
6372 using string_t =
typename BasicJsonType::string_t;
6373 using number_integer_t =
typename BasicJsonType::number_integer_t;
6374 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
6375 using number_float_t =
typename BasicJsonType::number_float_t;
6377 const auto type =
static_cast<std::size_t
>(j.type());
6380 case BasicJsonType::value_t::null:
6381 case BasicJsonType::value_t::discarded:
6386 case BasicJsonType::value_t::object:
6388 auto seed =
combine(type, j.size());
6389 for (
const auto& element : j.items())
6391 const auto h = std::hash<string_t> {}(element.key());
6398 case BasicJsonType::value_t::array:
6400 auto seed =
combine(type, j.size());
6401 for (
const auto& element : j)
6408 case BasicJsonType::value_t::string:
6410 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
6414 case BasicJsonType::value_t::boolean:
6416 const auto h = std::hash<bool> {}(j.template
get<bool>());
6420 case BasicJsonType::value_t::number_integer:
6426 case BasicJsonType::value_t::number_unsigned:
6432 case BasicJsonType::value_t::number_float:
6438 case BasicJsonType::value_t::binary:
6440 auto seed =
combine(type, j.get_binary().size());
6441 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
6443 seed =
combine(seed,
static_cast<std::size_t
>(j.get_binary().subtype()));
6444 for (
const auto byte : j.get_binary())
6446 seed =
combine(seed, std::hash<std::uint8_t> {}(byte));
6483#ifdef __cpp_lib_byteswap
6508#include <type_traits>
6562 return std::fgetc(m_file);
6569 return fread(dest, 1,
sizeof(T) * count, m_file);
6597 is->clear(is->rdstate() & std::ios::eofbit);
6602 : is(&i), sb(i.rdbuf())
6611 : is(rhs.is), sb(rhs.sb)
6622 auto res = sb->sbumpc();
6626 is->clear(is->rdstate() | std::ios::eofbit);
6634 auto res =
static_cast<std::size_t
>(sb->sgetn(
reinterpret_cast<char*
>(dest),
static_cast<std::streamsize
>(count *
sizeof(T))));
6637 is->clear(is->rdstate() | std::ios::eofbit);
6644 std::istream* is =
nullptr;
6645 std::streambuf* sb =
nullptr;
6651template<
typename IteratorType>
6655 using char_type =
typename std::iterator_traits<IteratorType>::value_type;
6658 : current(
std::move(first)), end(
std::move(last))
6666 std::advance(current, 1);
6677 auto* ptr =
reinterpret_cast<char*
>(dest);
6678 for (std::size_t read_index = 0; read_index < count *
sizeof(T); ++read_index)
6682 ptr[read_index] =
static_cast<char>(*current);
6683 std::advance(current, 1);
6690 return count *
sizeof(T);
6694 IteratorType current;
6697 template<
typename BaseInputAdapter,
size_t T>
6702 return current == end;
6706template<
typename BaseInputAdapter,
size_t T>
6709template<
typename BaseInputAdapter>
6714 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6715 size_t& utf8_bytes_index,
6716 size_t& utf8_bytes_filled)
6718 utf8_bytes_index = 0;
6722 utf8_bytes[0] = std::char_traits<char>::eof();
6723 utf8_bytes_filled = 1;
6728 const auto wc = input.get_character();
6733 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6734 utf8_bytes_filled = 1;
6736 else if (wc <= 0x7FF)
6738 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
6739 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6740 utf8_bytes_filled = 2;
6742 else if (wc <= 0xFFFF)
6744 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
6745 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6746 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6747 utf8_bytes_filled = 3;
6749 else if (wc <= 0x10FFFF)
6751 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
6752 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
6753 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6754 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6755 utf8_bytes_filled = 4;
6760 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6761 utf8_bytes_filled = 1;
6767template<
typename BaseInputAdapter>
6772 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6773 size_t& utf8_bytes_index,
6774 size_t& utf8_bytes_filled)
6776 utf8_bytes_index = 0;
6780 utf8_bytes[0] = std::char_traits<char>::eof();
6781 utf8_bytes_filled = 1;
6786 const auto wc = input.get_character();
6791 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6792 utf8_bytes_filled = 1;
6794 else if (wc <= 0x7FF)
6796 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
6797 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6798 utf8_bytes_filled = 2;
6800 else if (0xD800 > wc || wc >= 0xE000)
6802 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
6803 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6804 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6805 utf8_bytes_filled = 3;
6811 const auto wc2 =
static_cast<unsigned int>(input.get_character());
6812 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
6813 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
6814 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
6815 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
6816 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
6817 utf8_bytes_filled = 4;
6821 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6822 utf8_bytes_filled = 1;
6830template<
typename BaseInputAdapter,
typename W
ideCharType>
6837 : base_adapter(base) {}
6842 if (utf8_bytes_index == utf8_bytes_filled)
6844 fill_buffer<sizeof(WideCharType)>();
6852 JSON_ASSERT(utf8_bytes_index < utf8_bytes_filled);
6853 return utf8_bytes[utf8_bytes_index++];
6864 BaseInputAdapter base_adapter;
6873 std::array<std::char_traits<char>::int_type, 4> utf8_bytes = {{0, 0, 0, 0}};
6876 std::size_t utf8_bytes_index = 0;
6878 std::size_t utf8_bytes_filled = 0;
6881template<
typename IteratorType,
typename Enable =
void>
6885 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6890 return adapter_type(std::move(first), std::move(last));
6904template<
typename IteratorType>
6908 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6919template<
typename IteratorType>
6923 return factory_type::create(first, last);
6936template<
typename ContainerType,
typename Enable =
void>
6939template<
typename ContainerType>
6941 void_t<decltype(begin(
std::declval<ContainerType>()), end(std::declval<ContainerType>()))>>
6953template<
typename ContainerType>
6966 if (file ==
nullptr)
6968 JSON_THROW(
parse_error::create(101, 0,
"attempting to parse an empty input; check that your input string or stream contains the expected JSON",
nullptr));
6987template <
typename CharT,
6988 typename std::enable_if <
6989 std::is_pointer<CharT>::value&&
6990 !std::is_array<CharT>::value&&
6991 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
6992 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
6998 JSON_THROW(
parse_error::create(101, 0,
"attempting to parse an empty input; check that your input string or stream contains the expected JSON",
nullptr));
7000 auto length = std::strlen(
reinterpret_cast<const char*
>(b));
7001 const auto* ptr =
reinterpret_cast<const char*
>(b);
7005template<
typename T, std::
size_t N>
7017 template <
typename CharT,
7018 typename std::enable_if <
7019 std::is_pointer<CharT>::value&&
7020 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
7021 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
7024 : ia(
reinterpret_cast<const char*
>(b),
reinterpret_cast<const char*
>(b) + l) {}
7026 template<
class IteratorType,
7027 typename std::enable_if<
7028 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>
::value,
7035 return std::move(ia);
7058#include <type_traits>
7080#include <initializer_list>
7102template<
typename BasicJsonType>
7136 return "<uninitialized>";
7138 return "true literal";
7140 return "false literal";
7142 return "null literal";
7144 return "string literal";
7148 return "number literal";
7162 return "<parse error>";
7164 return "end of input";
7166 return "'[', '{', or a literal";
7169 return "unknown token";
7179template<
typename BasicJsonType,
typename InputAdapterType>
7182 using number_integer_t =
typename BasicJsonType::number_integer_t;
7183 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
7184 using number_float_t =
typename BasicJsonType::number_float_t;
7185 using string_t =
typename BasicJsonType::string_t;
7186 using char_type =
typename InputAdapterType::char_type;
7192 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false) noexcept
7193 : ia(
std::move(adapter))
7194 , ignore_comments(ignore_comments_)
7195 , decimal_point_char(static_cast<char_int_type>(get_decimal_point()))
7212 static char get_decimal_point() noexcept
7214 const auto* loc = localeconv();
7216 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
7244 const auto factors = { 12u, 8u, 4u, 0u };
7245 for (
const auto factor : factors)
7249 if (current >=
'0' && current <=
'9')
7251 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x30u) << factor);
7253 else if (current >=
'A' && current <=
'F')
7255 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x37u) << factor);
7257 else if (current >=
'a' && current <=
'f')
7259 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x57u) << factor);
7267 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
7286 bool next_byte_in_range(std::initializer_list<char_int_type> ranges)
7288 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
7291 for (
auto range = ranges.begin(); range != ranges.end(); ++range)
7300 error_message =
"invalid string: ill-formed UTF-8 byte";
7337 case char_traits<char_type>::eof():
7339 error_message =
"invalid string: missing closing quote";
7340 return token_type::parse_error;
7346 return token_type::value_string;
7390 const int codepoint1 = get_codepoint();
7391 int codepoint = codepoint1;
7395 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7396 return token_type::parse_error;
7400 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
7405 const int codepoint2 = get_codepoint();
7409 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7410 return token_type::parse_error;
7417 codepoint =
static_cast<int>(
7419 (
static_cast<unsigned int>(codepoint1) << 10u)
7421 +
static_cast<unsigned int>(codepoint2)
7429 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7430 return token_type::parse_error;
7435 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7436 return token_type::parse_error;
7443 error_message =
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
7444 return token_type::parse_error;
7449 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
7452 if (codepoint < 0x80)
7455 add(
static_cast<char_int_type
>(codepoint));
7457 else if (codepoint <= 0x7FF)
7460 add(
static_cast<char_int_type
>(0xC0u | (
static_cast<unsigned int>(codepoint) >> 6u)));
7461 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7463 else if (codepoint <= 0xFFFF)
7466 add(
static_cast<char_int_type
>(0xE0u | (
static_cast<unsigned int>(codepoint) >> 12u)));
7467 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7468 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7473 add(
static_cast<char_int_type
>(0xF0u | (
static_cast<unsigned int>(codepoint) >> 18u)));
7474 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
7475 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7476 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7484 error_message =
"invalid string: forbidden character after backslash";
7485 return token_type::parse_error;
7494 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
7495 return token_type::parse_error;
7500 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
7501 return token_type::parse_error;
7506 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
7507 return token_type::parse_error;
7512 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
7513 return token_type::parse_error;
7518 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
7519 return token_type::parse_error;
7524 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
7525 return token_type::parse_error;
7530 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
7531 return token_type::parse_error;
7536 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
7537 return token_type::parse_error;
7542 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
7543 return token_type::parse_error;
7548 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
7549 return token_type::parse_error;
7554 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
7555 return token_type::parse_error;
7560 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
7561 return token_type::parse_error;
7566 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
7567 return token_type::parse_error;
7572 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
7573 return token_type::parse_error;
7578 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
7579 return token_type::parse_error;
7584 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
7585 return token_type::parse_error;
7590 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
7591 return token_type::parse_error;
7596 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
7597 return token_type::parse_error;
7602 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
7603 return token_type::parse_error;
7608 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
7609 return token_type::parse_error;
7614 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
7615 return token_type::parse_error;
7620 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
7621 return token_type::parse_error;
7626 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
7627 return token_type::parse_error;
7632 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
7633 return token_type::parse_error;
7638 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
7639 return token_type::parse_error;
7644 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
7645 return token_type::parse_error;
7650 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
7651 return token_type::parse_error;
7656 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
7657 return token_type::parse_error;
7662 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
7663 return token_type::parse_error;
7668 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
7669 return token_type::parse_error;
7674 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
7675 return token_type::parse_error;
7680 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
7681 return token_type::parse_error;
7818 return token_type::parse_error;
7828 return token_type::parse_error;
7852 return token_type::parse_error;
7862 return token_type::parse_error;
7872 return token_type::parse_error;
7884 return token_type::parse_error;
7894 return token_type::parse_error;
7902 error_message =
"invalid string: ill-formed UTF-8 byte";
7903 return token_type::parse_error;
7946 error_message =
"invalid comment; missing closing '*/'";
7974 error_message =
"invalid comment; expecting '/' or '*' after '/'";
7981 static
void strtof(
float& f, const
char* str,
char** endptr) noexcept
7983 f = std::strtof(str, endptr);
7987 static
void strtof(
double& f, const
char* str,
char** endptr) noexcept
7989 f = std::strtod(str, endptr);
7993 static
void strtof(
long double& f, const
char* str,
char** endptr) noexcept
7995 f = std::strtold(str, endptr);
8038 token_type scan_number()
8045 token_type number_type = token_type::value_unsigned;
8053 goto scan_number_minus;
8059 goto scan_number_zero;
8073 goto scan_number_any1;
8083 number_type = token_type::value_integer;
8089 goto scan_number_zero;
8103 goto scan_number_any1;
8108 error_message =
"invalid number; expected digit after '-'";
8109 return token_type::parse_error;
8119 add(decimal_point_char);
8120 decimal_point_position = token_buffer.size() - 1;
8121 goto scan_number_decimal1;
8128 goto scan_number_exponent;
8132 goto scan_number_done;
8151 goto scan_number_any1;
8156 add(decimal_point_char);
8157 decimal_point_position = token_buffer.size() - 1;
8158 goto scan_number_decimal1;
8165 goto scan_number_exponent;
8169 goto scan_number_done;
8172scan_number_decimal1:
8174 number_type = token_type::value_float;
8189 goto scan_number_decimal2;
8194 error_message =
"invalid number; expected digit after '.'";
8195 return token_type::parse_error;
8199scan_number_decimal2:
8215 goto scan_number_decimal2;
8222 goto scan_number_exponent;
8226 goto scan_number_done;
8229scan_number_exponent:
8231 number_type = token_type::value_float;
8238 goto scan_number_sign;
8253 goto scan_number_any2;
8259 "invalid number; expected '+', '-', or digit after exponent";
8260 return token_type::parse_error;
8280 goto scan_number_any2;
8285 error_message =
"invalid number; expected digit after exponent sign";
8286 return token_type::parse_error;
8306 goto scan_number_any2;
8310 goto scan_number_done;
8318 char* endptr =
nullptr;
8322 if (number_type == token_type::value_unsigned)
8324 const auto x = std::strtoull(token_buffer.data(), &endptr, 10);
8327 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8329 if (errno != ERANGE)
8331 value_unsigned =
static_cast<number_unsigned_t
>(x);
8332 if (value_unsigned == x)
8334 return token_type::value_unsigned;
8338 else if (number_type == token_type::value_integer)
8340 const auto x = std::strtoll(token_buffer.data(), &endptr, 10);
8343 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8345 if (errno != ERANGE)
8347 value_integer =
static_cast<number_integer_t
>(x);
8348 if (value_integer == x)
8350 return token_type::value_integer;
8357 strtof(value_float, token_buffer.data(), &endptr);
8360 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8362 return token_type::value_float;
8371 token_type scan_literal(const char_type* literal_text, const std::
size_t length,
8372 token_type return_type)
8375 for (std::size_t i = 1; i < length; ++i)
8379 error_message =
"invalid literal";
8380 return token_type::parse_error;
8391 void reset() noexcept
8393 token_buffer.clear();
8394 token_string.clear();
8395 decimal_point_position = std::string::npos;
8411 ++position.chars_read_total;
8412 ++position.chars_read_current_line;
8421 current = ia.get_character();
8429 if (current ==
'\n')
8431 ++position.lines_read;
8432 position.chars_read_current_line = 0;
8450 --position.chars_read_total;
8453 if (position.chars_read_current_line == 0)
8455 if (position.lines_read > 0)
8457 --position.lines_read;
8462 --position.chars_read_current_line;
8468 token_string.pop_back();
8473 void add(char_int_type c)
8475 token_buffer.push_back(
static_cast<typename string_t::value_type
>(c));
8486 return value_integer;
8492 return value_unsigned;
8505 if (decimal_point_char !=
'.' && decimal_point_position != std::string::npos)
8507 token_buffer[decimal_point_position] =
'.';
8509 return token_buffer;
8529 for (
const auto c : token_string)
8531 if (
static_cast<unsigned char>(c) <=
'\x1F')
8534 std::array<char, 9> cs{{}};
8535 static_cast<void>((std::snprintf)(cs.data(), cs.size(),
"<U+%.4X>",
static_cast<unsigned char>(c)));
8536 result += cs.data();
8541 result.push_back(
static_cast<std::string::value_type
>(c));
8552 return error_message;
8568 return get() == 0xBB &&
get() == 0xBF;
8583 while (current ==
' ' || current ==
'\t' || current ==
'\n' || current ==
'\r');
8589 if (position.chars_read_total == 0 && !
skip_bom())
8591 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
8592 return token_type::parse_error;
8599 while (ignore_comments && current ==
'/')
8601 if (!scan_comment())
8603 return token_type::parse_error;
8614 return token_type::begin_array;
8616 return token_type::end_array;
8618 return token_type::begin_object;
8620 return token_type::end_object;
8622 return token_type::name_separator;
8624 return token_type::value_separator;
8629 std::array<char_type, 4> true_literal = {{
static_cast<char_type
>(
't'),
static_cast<char_type
>(
'r'),
static_cast<char_type
>(
'u'),
static_cast<char_type
>(
'e')}};
8630 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
8634 std::array<char_type, 5> false_literal = {{
static_cast<char_type
>(
'f'),
static_cast<char_type
>(
'a'),
static_cast<char_type
>(
'l'),
static_cast<char_type
>(
's'),
static_cast<char_type
>(
'e')}};
8635 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
8639 std::array<char_type, 4> null_literal = {{
static_cast<char_type
>(
'n'),
static_cast<char_type
>(
'u'),
static_cast<char_type
>(
'l'),
static_cast<char_type
>(
'l')}};
8640 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
8645 return scan_string();
8659 return scan_number();
8665 return token_type::end_of_input;
8669 error_message =
"invalid literal";
8670 return token_type::parse_error;
8676 InputAdapterType ia;
8679 const bool ignore_comments =
false;
8685 bool next_unget =
false;
8691 std::vector<char_type> token_string {};
8694 string_t token_buffer {};
8697 const char* error_message =
"";
8700 number_integer_t value_integer = 0;
8701 number_unsigned_t value_unsigned = 0;
8702 number_float_t value_float = 0;
8705 const char_int_type decimal_point_char =
'.';
8707 std::size_t decimal_point_position = std::string::npos;
8727template<
typename BasicJsonType>
8831 const std::string& last_token,
8846 return (std::numeric_limits<std::size_t>::max)();
8862template<
typename BasicJsonType,
typename InputAdapterType>
8879 : root(r), allow_exceptions(allow_exceptions_), m_lexer_ref(lexer_)
8891 handle_value(
nullptr);
8927 handle_value(std::move(val));
8933 ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
8935#if JSON_DIAGNOSTIC_POSITIONS
8942 ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
8960 object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val));
8969#if JSON_DIAGNOSTIC_POSITIONS
8973 ref_stack.back()->end_position = m_lexer_ref->get_position();
8977 ref_stack.back()->set_parents();
8978 ref_stack.pop_back();
8984 ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
8986#if JSON_DIAGNOSTIC_POSITIONS
8991 ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
9008#if JSON_DIAGNOSTIC_POSITIONS
9012 ref_stack.back()->end_position = m_lexer_ref->get_position();
9016 ref_stack.back()->set_parents();
9017 ref_stack.pop_back();
9021 template<
class Exception>
9023 const Exception& ex)
9026 static_cast<void>(ex);
9027 if (allow_exceptions)
9041#if JSON_DIAGNOSTIC_POSITIONS
9042 void handle_diagnostic_positions_for_json_value(BasicJsonType& v)
9049 v.end_position = m_lexer_ref->get_position();
9056 v.start_position = v.end_position - (v.m_data.m_value.boolean ? 4 : 5);
9063 v.start_position = v.end_position - 4;
9067 case value_t::string:
9070 v.start_position = v.end_position - v.m_data.m_value.string->size() - 2;
9079 case value_t::discarded:
9081 v.end_position = std::string::npos;
9082 v.start_position = v.end_position;
9086 case value_t::binary:
9087 case value_t::number_integer:
9088 case value_t::number_unsigned:
9089 case value_t::number_float:
9091 v.start_position = v.end_position - m_lexer_ref->get_string().size();
9094 case value_t::object:
9095 case value_t::array:
9115 template<
typename Value>
9117 BasicJsonType* handle_value(Value&& v)
9119 if (ref_stack.empty())
9121 root = BasicJsonType(std::forward<Value>(v));
9123#if JSON_DIAGNOSTIC_POSITIONS
9124 handle_diagnostic_positions_for_json_value(root);
9130 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
9132 if (ref_stack.back()->is_array())
9134 ref_stack.back()->m_data.m_value.array->emplace_back(std::forward<Value>(v));
9136#if JSON_DIAGNOSTIC_POSITIONS
9137 handle_diagnostic_positions_for_json_value(ref_stack.back()->m_data.m_value.array->back());
9140 return &(ref_stack.back()->m_data.m_value.array->back());
9145 *object_element = BasicJsonType(std::forward<Value>(v));
9147#if JSON_DIAGNOSTIC_POSITIONS
9148 handle_diagnostic_positions_for_json_value(*object_element);
9151 return object_element;
9155 BasicJsonType& root;
9157 std::vector<BasicJsonType*> ref_stack {};
9159 BasicJsonType* object_element =
nullptr;
9161 bool errored =
false;
9163 const bool allow_exceptions =
true;
9165 lexer_t* m_lexer_ref =
nullptr;
9168template<
typename BasicJsonType,
typename InputAdapterType>
9183 const bool allow_exceptions_ =
true,
9185 : root(r), callback(
std::move(cb)), allow_exceptions(allow_exceptions_), m_lexer_ref(lexer_)
9187 keep_stack.push_back(
true);
9199 handle_value(
nullptr);
9235 handle_value(std::move(val));
9243 keep_stack.push_back(keep);
9245 auto val = handle_value(BasicJsonType::value_t::object,
true);
9246 ref_stack.push_back(val.second);
9248 if (ref_stack.back())
9251#if JSON_DIAGNOSTIC_POSITIONS
9258 ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
9273 BasicJsonType k = BasicJsonType(val);
9276 const bool keep = callback(
static_cast<int>(ref_stack.size()),
parse_event_t::key, k);
9277 key_keep_stack.push_back(keep);
9280 if (keep && ref_stack.back())
9282 object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val) = discarded);
9290 if (ref_stack.back())
9295 *ref_stack.back() = discarded;
9297#if JSON_DIAGNOSTIC_POSITIONS
9299 handle_diagnostic_positions_for_json_value(*ref_stack.back());
9305#if JSON_DIAGNOSTIC_POSITIONS
9309 ref_stack.back()->end_position = m_lexer_ref->get_position();
9313 ref_stack.back()->set_parents();
9319 ref_stack.pop_back();
9320 keep_stack.pop_back();
9322 if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
9325 for (
auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
9327 if (it->is_discarded())
9329 ref_stack.back()->erase(it);
9341 keep_stack.push_back(keep);
9343 auto val = handle_value(BasicJsonType::value_t::array,
true);
9344 ref_stack.push_back(val.second);
9346 if (ref_stack.back())
9349#if JSON_DIAGNOSTIC_POSITIONS
9356 ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
9374 if (ref_stack.back())
9380#if JSON_DIAGNOSTIC_POSITIONS
9384 ref_stack.back()->end_position = m_lexer_ref->get_position();
9388 ref_stack.back()->set_parents();
9393 *ref_stack.back() = discarded;
9395#if JSON_DIAGNOSTIC_POSITIONS
9397 handle_diagnostic_positions_for_json_value(*ref_stack.back());
9404 ref_stack.pop_back();
9405 keep_stack.pop_back();
9408 if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
9410 ref_stack.back()->m_data.m_value.array->pop_back();
9416 template<
class Exception>
9418 const Exception& ex)
9421 static_cast<void>(ex);
9422 if (allow_exceptions)
9436#if JSON_DIAGNOSTIC_POSITIONS
9437 void handle_diagnostic_positions_for_json_value(BasicJsonType& v)
9444 v.end_position = m_lexer_ref->get_position();
9451 v.start_position = v.end_position - (v.m_data.m_value.boolean ? 4 : 5);
9458 v.start_position = v.end_position - 4;
9462 case value_t::string:
9465 v.start_position = v.end_position - v.m_data.m_value.string->size() - 2;
9469 case value_t::discarded:
9471 v.end_position = std::string::npos;
9472 v.start_position = v.end_position;
9476 case value_t::binary:
9477 case value_t::number_integer:
9478 case value_t::number_unsigned:
9479 case value_t::number_float:
9481 v.start_position = v.end_position - m_lexer_ref->get_string().size();
9485 case value_t::object:
9486 case value_t::array:
9515 template<
typename Value>
9516 std::pair<bool, BasicJsonType*> handle_value(Value&& v,
const bool skip_callback =
false)
9522 if (!keep_stack.back())
9524 return {
false,
nullptr};
9528 auto value = BasicJsonType(std::forward<Value>(v));
9530#if JSON_DIAGNOSTIC_POSITIONS
9531 handle_diagnostic_positions_for_json_value(value);
9535 const bool keep = skip_callback || callback(
static_cast<int>(ref_stack.size()), parse_event_t::value, value);
9540 return {
false,
nullptr};
9543 if (ref_stack.empty())
9545 root = std::move(value);
9546 return {
true, & root};
9551 if (!ref_stack.back())
9553 return {
false,
nullptr};
9557 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
9560 if (ref_stack.back()->is_array())
9562 ref_stack.back()->m_data.m_value.array->emplace_back(std::move(value));
9563 return {
true, & (ref_stack.back()->m_data.m_value.array->back())};
9570 const bool store_element = key_keep_stack.back();
9571 key_keep_stack.pop_back();
9575 return {
false,
nullptr};
9579 *object_element = std::move(value);
9580 return {
true, object_element};
9584 BasicJsonType& root;
9586 std::vector<BasicJsonType*> ref_stack {};
9588 std::vector<bool> keep_stack {};
9590 std::vector<bool> key_keep_stack {};
9592 BasicJsonType* object_element =
nullptr;
9594 bool errored =
false;
9598 const bool allow_exceptions =
true;
9600 BasicJsonType
discarded = BasicJsonType::value_t::discarded;
9602 lexer_t* m_lexer_ref =
nullptr;
9605template<
typename BasicJsonType>
9719 decltype(std::declval<T&>().boolean(std::declval<bool>()));
9721template<
typename T,
typename Integer>
9723 decltype(std::declval<T&>().number_integer(std::declval<Integer>()));
9725template<
typename T,
typename Un
signed>
9727 decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
9729template<
typename T,
typename Float,
typename String>
9731 std::declval<Float>(), std::declval<const String&>()));
9733template<
typename T,
typename String>
9735 decltype(std::declval<T&>().string(std::declval<String&>()));
9737template<
typename T,
typename Binary>
9739 decltype(std::declval<T&>().binary(std::declval<Binary&>()));
9743 decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
9745template<
typename T,
typename String>
9747 decltype(std::declval<T&>().key(std::declval<String&>()));
9754 decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
9759template<
typename T,
typename Exception>
9761 std::declval<std::size_t>(), std::declval<const std::string&>(),
9762 std::declval<const Exception&>()));
9764template<
typename SAX,
typename BasicJsonType>
9769 "BasicJsonType must be of type basic_json<...>");
9771 using number_integer_t =
typename BasicJsonType::number_integer_t;
9772 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
9773 using number_float_t =
typename BasicJsonType::number_float_t;
9774 using string_t =
typename BasicJsonType::string_t;
9775 using binary_t =
typename BasicJsonType::binary_t;
9776 using exception_t =
typename BasicJsonType::exception;
9795template<
typename SAX,
typename BasicJsonType>
9800 "BasicJsonType must be of type basic_json<...>");
9802 using number_integer_t =
typename BasicJsonType::number_integer_t;
9803 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
9804 using number_float_t =
typename BasicJsonType::number_float_t;
9805 using string_t =
typename BasicJsonType::string_t;
9806 using binary_t =
typename BasicJsonType::binary_t;
9807 using exception_t =
typename BasicJsonType::exception;
9811 "Missing/invalid function: bool null()");
9813 "Missing/invalid function: bool boolean(bool)");
9815 "Missing/invalid function: bool boolean(bool)");
9819 "Missing/invalid function: bool number_integer(number_integer_t)");
9823 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
9825 number_float_t, string_t>
::value,
9826 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
9829 "Missing/invalid function: bool string(string_t&)");
9832 "Missing/invalid function: bool binary(binary_t&)");
9834 "Missing/invalid function: bool start_object(std::size_t)");
9836 "Missing/invalid function: bool key(string_t&)");
9838 "Missing/invalid function: bool end_object()");
9840 "Missing/invalid function: bool start_array(std::size_t)");
9842 "Missing/invalid function: bool end_array()");
9845 "Missing/invalid function: bool parse_error(std::size_t, const "
9846 "std::string&, const exception&)");
9880 return *
reinterpret_cast<char*
>(&num) == 1;
9890template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
9893 using number_integer_t =
typename BasicJsonType::number_integer_t;
9894 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
9895 using number_float_t =
typename BasicJsonType::number_float_t;
9896 using string_t =
typename BasicJsonType::string_t;
9897 using binary_t =
typename BasicJsonType::binary_t;
9898 using json_sax_t = SAX;
9899 using char_type =
typename InputAdapterType::char_type;
9931 const
bool strict = true,
9935 bool result =
false;
9940 result = parse_bson_internal();
9944 result = parse_cbor_internal(
true, tag_handler);
9948 result = parse_msgpack_internal();
9953 result = parse_ubjson_internal();
9975 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(110, chars_read,
9976 exception_message(input_format,
concat(
"expected end of input; last byte: 0x", get_token_string()),
"value"),
nullptr));
9992 bool parse_bson_internal()
9994 std::int32_t document_size{};
9995 get_number<std::int32_t, true>(input_format_t::bson, document_size);
10007 return sax->end_object();
10017 bool get_bson_cstr(string_t& result)
10019 auto out = std::back_inserter(result);
10027 if (current == 0x00)
10031 *out++ =
static_cast<typename string_t::value_type
>(current);
10046 template<
typename NumberType>
10047 bool get_bson_string(
const NumberType len, string_t& result)
10051 auto last_token = get_token_string();
10052 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10053 exception_message(input_format_t::bson,
concat(
"string length must be at least 1, is ", std::to_string(len)),
"string"),
nullptr));
10056 return get_string(input_format_t::bson, len -
static_cast<NumberType
>(1), result) &&
get() != char_traits<char_type>::eof();
10068 template<
typename NumberType>
10069 bool get_bson_binary(
const NumberType len, binary_t& result)
10073 auto last_token = get_token_string();
10074 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10075 exception_message(input_format_t::bson,
concat(
"byte array length cannot be negative, is ", std::to_string(len)),
"binary"),
nullptr));
10079 std::uint8_t subtype{};
10080 get_number<std::uint8_t>(input_format_t::bson, subtype);
10081 result.set_subtype(subtype);
10083 return get_binary(input_format_t::bson, len, result);
10096 bool parse_bson_element_internal(
const char_int_type element_type,
10097 const std::size_t element_type_parse_position)
10099 switch (element_type)
10104 return get_number<double, true>(input_format_t::bson, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10109 std::int32_t len{};
10111 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_string(len, value) && sax->string(value);
10116 return parse_bson_internal();
10121 return parse_bson_array();
10126 std::int32_t len{};
10128 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_binary(len, value) && sax->binary(value);
10133 return sax->boolean(
get() != 0);
10138 return sax->null();
10143 std::int32_t
value{};
10144 return get_number<std::int32_t, true>(input_format_t::bson, value) && sax->number_integer(value);
10149 std::int64_t
value{};
10150 return get_number<std::int64_t, true>(input_format_t::bson, value) && sax->number_integer(value);
10155 std::uint64_t
value{};
10156 return get_number<std::uint64_t, true>(input_format_t::bson, value) && sax->number_unsigned(value);
10161 std::array<char, 3> cr{{}};
10162 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(element_type)));
10163 const std::string cr_str{cr.data()};
10164 return sax->parse_error(element_type_parse_position, cr_str,
10165 parse_error::create(114, element_type_parse_position,
concat(
"Unsupported BSON record type 0x", cr_str),
nullptr));
10182 bool parse_bson_element_list(
const bool is_array)
10186 while (
auto element_type =
get())
10193 const std::size_t element_type_parse_position = chars_read;
10199 if (!is_array && !sax->key(key))
10204 if (
JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position)))
10220 bool parse_bson_array()
10222 std::int32_t document_size{};
10223 get_number<std::int32_t, true>(input_format_t::bson, document_size);
10235 return sax->end_array();
10250 bool parse_cbor_internal(
const bool get_char,
10251 const cbor_tag_handler_t tag_handler)
10253 switch (get_char ?
get() : current)
10256 case char_traits<char_type>::eof():
10284 return sax->number_unsigned(
static_cast<number_unsigned_t
>(current));
10288 std::uint8_t number{};
10289 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
10294 std::uint16_t number{};
10295 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
10300 std::uint32_t number{};
10301 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
10306 std::uint64_t number{};
10307 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
10335 return sax->number_integer(
static_cast<std::int8_t
>(0x20 - 1 - current));
10339 std::uint8_t number{};
10340 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
10345 std::uint16_t number{};
10346 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
10351 std::uint32_t number{};
10352 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
10357 std::uint64_t number{};
10358 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1)
10359 -
static_cast<number_integer_t
>(number));
10394 return get_cbor_binary(b) && sax->binary(b);
10429 return get_cbor_string(s) && sax->string(s);
10457 return get_cbor_array(
10458 conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
10462 std::uint8_t len{};
10463 return get_number(input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
10468 std::uint16_t len{};
10469 return get_number(input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
10474 std::uint32_t len{};
10475 return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
10480 std::uint64_t len{};
10481 return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
10512 return get_cbor_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
10516 std::uint8_t len{};
10517 return get_number(input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
10522 std::uint16_t len{};
10523 return get_number(input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
10528 std::uint32_t len{};
10529 return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
10534 std::uint64_t len{};
10535 return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
10561 switch (tag_handler)
10563 case cbor_tag_handler_t::error:
10565 auto last_token = get_token_string();
10566 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10567 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
10570 case cbor_tag_handler_t::ignore:
10577 std::uint8_t subtype_to_ignore{};
10578 get_number(input_format_t::cbor, subtype_to_ignore);
10583 std::uint16_t subtype_to_ignore{};
10584 get_number(input_format_t::cbor, subtype_to_ignore);
10589 std::uint32_t subtype_to_ignore{};
10590 get_number(input_format_t::cbor, subtype_to_ignore);
10595 std::uint64_t subtype_to_ignore{};
10596 get_number(input_format_t::cbor, subtype_to_ignore);
10602 return parse_cbor_internal(
true, tag_handler);
10605 case cbor_tag_handler_t::store:
10613 std::uint8_t subtype{};
10614 get_number(input_format_t::cbor, subtype);
10620 std::uint16_t subtype{};
10621 get_number(input_format_t::cbor, subtype);
10627 std::uint32_t subtype{};
10628 get_number(input_format_t::cbor, subtype);
10634 std::uint64_t subtype{};
10635 get_number(input_format_t::cbor, subtype);
10640 return parse_cbor_internal(
true, tag_handler);
10643 return get_cbor_binary(b) && sax->binary(b);
10653 return sax->boolean(
false);
10656 return sax->boolean(
true);
10659 return sax->null();
10663 const auto byte1_raw =
get();
10668 const auto byte2_raw =
get();
10674 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
10675 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
10685 const auto half =
static_cast<unsigned int>((byte1 << 8u) + byte2);
10686 const double val = [&half]
10688 const int exp = (half >> 10u) & 0x1Fu;
10689 const unsigned int mant = half & 0x3FFu;
10695 return std::ldexp(mant, -24);
10698 ? std::numeric_limits<double>::infinity()
10699 : std::numeric_limits<double>::quiet_NaN();
10701 return std::ldexp(mant + 1024, exp - 25);
10704 return sax->number_float((half & 0x8000u) != 0
10705 ?
static_cast<number_float_t
>(-val)
10706 :
static_cast<number_float_t
>(val),
"");
10712 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10718 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10723 auto last_token = get_token_string();
10724 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10725 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
10741 bool get_cbor_string(string_t& result)
10776 return get_string(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu, result);
10781 std::uint8_t len{};
10782 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10787 std::uint16_t len{};
10788 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10793 std::uint32_t len{};
10794 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10799 std::uint64_t len{};
10800 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10805 while (
get() != 0xFF)
10808 if (!get_cbor_string(chunk))
10812 result.append(chunk);
10819 auto last_token = get_token_string();
10820 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
10821 exception_message(input_format_t::cbor,
concat(
"expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token),
"string"),
nullptr));
10837 bool get_cbor_binary(binary_t& result)
10872 return get_binary(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu, result);
10877 std::uint8_t len{};
10878 return get_number(input_format_t::cbor, len) &&
10879 get_binary(input_format_t::cbor, len, result);
10884 std::uint16_t len{};
10885 return get_number(input_format_t::cbor, len) &&
10886 get_binary(input_format_t::cbor, len, result);
10891 std::uint32_t len{};
10892 return get_number(input_format_t::cbor, len) &&
10893 get_binary(input_format_t::cbor, len, result);
10898 std::uint64_t len{};
10899 return get_number(input_format_t::cbor, len) &&
10900 get_binary(input_format_t::cbor, len, result);
10905 while (
get() != 0xFF)
10908 if (!get_cbor_binary(chunk))
10912 result.insert(result.end(), chunk.begin(), chunk.end());
10919 auto last_token = get_token_string();
10920 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
10921 exception_message(input_format_t::cbor,
concat(
"expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x", last_token),
"binary"),
nullptr));
10932 bool get_cbor_array(
const std::size_t len,
10933 const cbor_tag_handler_t tag_handler)
10942 for (std::size_t i = 0; i < len; ++i)
10952 while (
get() != 0xFF)
10961 return sax->end_array();
10970 bool get_cbor_object(
const std::size_t len,
10971 const cbor_tag_handler_t tag_handler)
10983 for (std::size_t i = 0; i < len; ++i)
11000 while (
get() != 0xFF)
11016 return sax->end_object();
11026 bool parse_msgpack_internal()
11031 case char_traits<char_type>::eof():
11163 return sax->number_unsigned(
static_cast<number_unsigned_t
>(current));
11182 return get_msgpack_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
11201 return get_msgpack_array(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
11241 return get_msgpack_string(s) && sax->string(s);
11245 return sax->null();
11248 return sax->boolean(
false);
11251 return sax->boolean(
true);
11266 return get_msgpack_binary(b) && sax->binary(b);
11272 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
11278 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
11283 std::uint8_t number{};
11284 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
11289 std::uint16_t number{};
11290 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
11295 std::uint32_t number{};
11296 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
11301 std::uint64_t number{};
11302 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
11307 std::int8_t number{};
11308 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
11313 std::int16_t number{};
11314 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
11319 std::int32_t number{};
11320 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
11325 std::int64_t number{};
11326 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
11331 std::uint16_t len{};
11332 return get_number(input_format_t::msgpack, len) && get_msgpack_array(
static_cast<std::size_t
>(len));
11337 std::uint32_t len{};
11338 return get_number(input_format_t::msgpack, len) && get_msgpack_array(conditional_static_cast<std::size_t>(len));
11343 std::uint16_t len{};
11344 return get_number(input_format_t::msgpack, len) && get_msgpack_object(
static_cast<std::size_t
>(len));
11349 std::uint32_t len{};
11350 return get_number(input_format_t::msgpack, len) && get_msgpack_object(conditional_static_cast<std::size_t>(len));
11386 return sax->number_integer(
static_cast<std::int8_t
>(current));
11390 auto last_token = get_token_string();
11391 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
11392 exception_message(input_format_t::msgpack,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
11407 bool get_msgpack_string(string_t& result)
11450 return get_string(input_format_t::msgpack,
static_cast<unsigned int>(current) & 0x1Fu, result);
11455 std::uint8_t len{};
11456 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
11461 std::uint16_t len{};
11462 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
11467 std::uint32_t len{};
11468 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
11473 auto last_token = get_token_string();
11474 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
11475 exception_message(input_format_t::msgpack,
concat(
"expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token),
"string"),
nullptr));
11490 bool get_msgpack_binary(binary_t& result)
11493 auto assign_and_return_true = [&result](std::int8_t subtype)
11495 result.set_subtype(
static_cast<std::uint8_t
>(subtype));
11503 std::uint8_t len{};
11504 return get_number(input_format_t::msgpack, len) &&
11505 get_binary(input_format_t::msgpack, len, result);
11510 std::uint16_t len{};
11511 return get_number(input_format_t::msgpack, len) &&
11512 get_binary(input_format_t::msgpack, len, result);
11517 std::uint32_t len{};
11518 return get_number(input_format_t::msgpack, len) &&
11519 get_binary(input_format_t::msgpack, len, result);
11524 std::uint8_t len{};
11525 std::int8_t subtype{};
11526 return get_number(input_format_t::msgpack, len) &&
11527 get_number(input_format_t::msgpack, subtype) &&
11528 get_binary(input_format_t::msgpack, len, result) &&
11529 assign_and_return_true(subtype);
11534 std::uint16_t len{};
11535 std::int8_t subtype{};
11536 return get_number(input_format_t::msgpack, len) &&
11537 get_number(input_format_t::msgpack, subtype) &&
11538 get_binary(input_format_t::msgpack, len, result) &&
11539 assign_and_return_true(subtype);
11544 std::uint32_t len{};
11545 std::int8_t subtype{};
11546 return get_number(input_format_t::msgpack, len) &&
11547 get_number(input_format_t::msgpack, subtype) &&
11548 get_binary(input_format_t::msgpack, len, result) &&
11549 assign_and_return_true(subtype);
11554 std::int8_t subtype{};
11555 return get_number(input_format_t::msgpack, subtype) &&
11556 get_binary(input_format_t::msgpack, 1, result) &&
11557 assign_and_return_true(subtype);
11562 std::int8_t subtype{};
11563 return get_number(input_format_t::msgpack, subtype) &&
11564 get_binary(input_format_t::msgpack, 2, result) &&
11565 assign_and_return_true(subtype);
11570 std::int8_t subtype{};
11571 return get_number(input_format_t::msgpack, subtype) &&
11572 get_binary(input_format_t::msgpack, 4, result) &&
11573 assign_and_return_true(subtype);
11578 std::int8_t subtype{};
11579 return get_number(input_format_t::msgpack, subtype) &&
11580 get_binary(input_format_t::msgpack, 8, result) &&
11581 assign_and_return_true(subtype);
11586 std::int8_t subtype{};
11587 return get_number(input_format_t::msgpack, subtype) &&
11588 get_binary(input_format_t::msgpack, 16, result) &&
11589 assign_and_return_true(subtype);
11601 bool get_msgpack_array(
const std::size_t len)
11608 for (std::size_t i = 0; i < len; ++i)
11616 return sax->end_array();
11623 bool get_msgpack_object(
const std::size_t len)
11631 for (std::size_t i = 0; i < len; ++i)
11646 return sax->end_object();
11660 bool parse_ubjson_internal(
const bool get_char =
true)
11662 return get_ubjson_value(get_char ? get_ignore_noop() : current);
11679 bool get_ubjson_string(string_t& result,
const bool get_char =
true)
11695 std::uint8_t len{};
11696 return get_number(input_format, len) && get_string(input_format, len, result);
11702 return get_number(input_format, len) && get_string(input_format, len, result);
11707 std::int16_t len{};
11708 return get_number(input_format, len) && get_string(input_format, len, result);
11713 std::int32_t len{};
11714 return get_number(input_format, len) && get_string(input_format, len, result);
11719 std::int64_t len{};
11720 return get_number(input_format, len) && get_string(input_format, len, result);
11725 if (input_format != input_format_t::bjdata)
11729 std::uint16_t len{};
11730 return get_number(input_format, len) && get_string(input_format, len, result);
11735 if (input_format != input_format_t::bjdata)
11739 std::uint32_t len{};
11740 return get_number(input_format, len) && get_string(input_format, len, result);
11745 if (input_format != input_format_t::bjdata)
11749 std::uint64_t len{};
11750 return get_number(input_format, len) && get_string(input_format, len, result);
11756 auto last_token = get_token_string();
11757 std::string message;
11759 if (input_format != input_format_t::bjdata)
11761 message =
"expected length type specification (U, i, I, l, L); last byte: 0x" + last_token;
11765 message =
"expected length type specification (U, i, u, I, m, l, M, L); last byte: 0x" + last_token;
11767 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, message,
"string"),
nullptr));
11774 bool get_ubjson_ndarray_size(std::vector<size_t>& dim)
11776 std::pair<std::size_t, char_int_type> size_and_type;
11778 bool no_ndarray =
true;
11785 if (size_and_type.first != npos)
11787 if (size_and_type.second != 0)
11789 if (size_and_type.second !=
'N')
11791 for (std::size_t i = 0; i < size_and_type.first; ++i)
11797 dim.push_back(dimlen);
11803 for (std::size_t i = 0; i < size_and_type.first; ++i)
11809 dim.push_back(dimlen);
11815 while (current !=
']')
11821 dim.push_back(dimlen);
11839 bool get_ubjson_size_value(std::size_t& result,
bool& is_ndarray, char_int_type prefix = 0)
11843 prefix = get_ignore_noop();
11850 std::uint8_t number{};
11855 result =
static_cast<std::size_t
>(number);
11861 std::int8_t number{};
11868 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11869 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11871 result =
static_cast<std::size_t
>(number);
11877 std::int16_t number{};
11884 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11885 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11887 result =
static_cast<std::size_t
>(number);
11893 std::int32_t number{};
11900 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11901 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11903 result =
static_cast<std::size_t
>(number);
11909 std::int64_t number{};
11916 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11917 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11919 if (!value_in_range_of<std::size_t>(number))
11921 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408,
11922 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11924 result =
static_cast<std::size_t
>(number);
11930 if (input_format != input_format_t::bjdata)
11934 std::uint16_t number{};
11939 result =
static_cast<std::size_t
>(number);
11945 if (input_format != input_format_t::bjdata)
11949 std::uint32_t number{};
11954 result = conditional_static_cast<std::size_t>(number);
11960 if (input_format != input_format_t::bjdata)
11964 std::uint64_t number{};
11969 if (!value_in_range_of<std::size_t>(number))
11971 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408,
11972 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11980 if (input_format != input_format_t::bjdata)
11986 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format,
"ndarray dimensional vector is not allowed",
"size"),
nullptr));
11988 std::vector<size_t> dim;
11993 if (dim.size() == 1 || (dim.size() == 2 && dim.at(0) == 1))
11995 result = dim.at(dim.size() - 1);
12009 string_t
key =
"_ArraySize_";
12010 if (
JSON_HEDLEY_UNLIKELY(!sax->start_object(3) || !sax->key(key) || !sax->start_array(dim.size())))
12022 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, exception_message(input_format,
"excessive ndarray size caused overflow",
"size"),
nullptr));
12026 if (result == 0 || result == npos)
12028 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, exception_message(input_format,
"excessive ndarray size caused overflow",
"size"),
nullptr));
12036 return sax->end_array();
12045 auto last_token = get_token_string();
12046 std::string message;
12048 if (input_format != input_format_t::bjdata)
12050 message =
"expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token;
12054 message =
"expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x" + last_token;
12056 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, message,
"size"),
nullptr));
12070 bool get_ubjson_size_type(std::pair<std::size_t, char_int_type>& result,
bool inside_ndarray =
false)
12072 result.first = npos;
12074 bool is_ndarray =
false;
12078 if (current ==
'$')
12080 result.second =
get();
12081 if (input_format == input_format_t::bjdata
12082 &&
JSON_HEDLEY_UNLIKELY(std::binary_search(bjd_optimized_type_markers.begin(), bjd_optimized_type_markers.end(), result.second)))
12084 auto last_token = get_token_string();
12085 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
12086 exception_message(input_format,
concat(
"marker 0x", last_token,
" is not a permitted optimized array type"),
"type"),
nullptr));
12101 auto last_token = get_token_string();
12102 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
12103 exception_message(input_format,
concat(
"expected '#' after type information; last byte: 0x", last_token),
"size"),
nullptr));
12106 const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
12107 if (input_format == input_format_t::bjdata && is_ndarray)
12109 if (inside_ndarray)
12111 return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read,
12112 exception_message(input_format,
"ndarray can not be recursive",
"size"),
nullptr));
12114 result.second |= (1 << 8);
12119 if (current ==
'#')
12121 const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
12122 if (input_format == input_format_t::bjdata && is_ndarray)
12124 return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read,
12125 exception_message(input_format,
"ndarray requires both type and size",
"size"),
nullptr));
12137 bool get_ubjson_value(
const char_int_type prefix)
12141 case char_traits<char_type>::eof():
12142 return unexpect_eof(input_format,
"value");
12145 return sax->boolean(
true);
12147 return sax->boolean(
false);
12150 return sax->null();
12154 if (input_format != input_format_t::bjdata)
12158 std::uint8_t number{};
12159 return get_number(input_format, number) && sax->number_unsigned(number);
12164 std::uint8_t number{};
12165 return get_number(input_format, number) && sax->number_unsigned(number);
12170 std::int8_t number{};
12171 return get_number(input_format, number) && sax->number_integer(number);
12176 std::int16_t number{};
12177 return get_number(input_format, number) && sax->number_integer(number);
12182 std::int32_t number{};
12183 return get_number(input_format, number) && sax->number_integer(number);
12188 std::int64_t number{};
12189 return get_number(input_format, number) && sax->number_integer(number);
12194 if (input_format != input_format_t::bjdata)
12198 std::uint16_t number{};
12199 return get_number(input_format, number) && sax->number_unsigned(number);
12204 if (input_format != input_format_t::bjdata)
12208 std::uint32_t number{};
12209 return get_number(input_format, number) && sax->number_unsigned(number);
12214 if (input_format != input_format_t::bjdata)
12218 std::uint64_t number{};
12219 return get_number(input_format, number) && sax->number_unsigned(number);
12224 if (input_format != input_format_t::bjdata)
12228 const auto byte1_raw =
get();
12233 const auto byte2_raw =
get();
12239 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
12240 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
12250 const auto half =
static_cast<unsigned int>((byte2 << 8u) + byte1);
12251 const double val = [&half]
12253 const int exp = (half >> 10u) & 0x1Fu;
12254 const unsigned int mant = half & 0x3FFu;
12260 return std::ldexp(mant, -24);
12263 ? std::numeric_limits<double>::infinity()
12264 : std::numeric_limits<double>::quiet_NaN();
12266 return std::ldexp(mant + 1024, exp - 25);
12269 return sax->number_float((half & 0x8000u) != 0
12270 ?
static_cast<number_float_t
>(-val)
12271 :
static_cast<number_float_t
>(val),
"");
12277 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
12283 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
12288 return get_ubjson_high_precision_number();
12300 auto last_token = get_token_string();
12301 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
12302 exception_message(input_format,
concat(
"byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token),
"char"),
nullptr));
12304 string_t s(1,
static_cast<typename string_t::value_type
>(current));
12305 return sax->string(s);
12311 return get_ubjson_string(s) && sax->string(s);
12315 return get_ubjson_array();
12318 return get_ubjson_object();
12323 auto last_token = get_token_string();
12324 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format,
"invalid byte: 0x" + last_token,
"value"),
nullptr));
12330 bool get_ubjson_array()
12332 std::pair<std::size_t, char_int_type> size_and_type;
12341 if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
12343 size_and_type.second &= ~(
static_cast<char_int_type
>(1) << 8);
12344 auto it = std::lower_bound(bjd_types_map.begin(), bjd_types_map.end(), size_and_type.second, [](
const bjd_type & p, char_int_type t)
12346 return p.first < t;
12348 string_t
key =
"_ArrayType_";
12351 auto last_token = get_token_string();
12352 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
12353 exception_message(input_format,
"invalid byte: 0x" + last_token,
"type"),
nullptr));
12356 string_t type = it->second;
12362 if (size_and_type.second ==
'C' || size_and_type.second ==
'B')
12364 size_and_type.second =
'U';
12367 key =
"_ArrayData_";
12373 for (std::size_t i = 0; i < size_and_type.first; ++i)
12381 return (sax->end_array() && sax->end_object());
12385 if (input_format == input_format_t::bjdata && size_and_type.first != npos && size_and_type.second ==
'B')
12388 return get_binary(input_format, size_and_type.first, result) && sax->binary(result);
12391 if (size_and_type.first != npos)
12398 if (size_and_type.second != 0)
12400 if (size_and_type.second !=
'N')
12402 for (std::size_t i = 0; i < size_and_type.first; ++i)
12413 for (std::size_t i = 0; i < size_and_type.first; ++i)
12429 while (current !=
']')
12439 return sax->end_array();
12445 bool get_ubjson_object()
12447 std::pair<std::size_t, char_int_type> size_and_type;
12454 if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
12456 auto last_token = get_token_string();
12457 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
12458 exception_message(input_format,
"BJData object does not support ND-array size in optimized format",
"object"),
nullptr));
12462 if (size_and_type.first != npos)
12469 if (size_and_type.second != 0)
12471 for (std::size_t i = 0; i < size_and_type.first; ++i)
12486 for (std::size_t i = 0; i < size_and_type.first; ++i)
12507 while (current !=
'}')
12522 return sax->end_object();
12528 bool get_ubjson_high_precision_number()
12531 std::size_t size{};
12532 bool no_ndarray =
true;
12533 auto res = get_ubjson_size_value(size, no_ndarray);
12540 std::vector<char> number_vector;
12541 for (std::size_t i = 0; i < size; ++i)
12548 number_vector.push_back(
static_cast<char>(current));
12553 auto number_lexer = detail::lexer<BasicJsonType, ia_type>(
detail::input_adapter(number_vector),
false);
12554 const auto result_number = number_lexer.scan();
12555 const auto number_string = number_lexer.get_token_string();
12556 const auto result_remainder = number_lexer.scan();
12562 return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read,
12563 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
12566 switch (result_number)
12568 case token_type::value_integer:
12569 return sax->number_integer(number_lexer.get_number_integer());
12570 case token_type::value_unsigned:
12571 return sax->number_unsigned(number_lexer.get_number_unsigned());
12572 case token_type::value_float:
12573 return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
12574 case token_type::uninitialized:
12575 case token_type::literal_true:
12576 case token_type::literal_false:
12577 case token_type::literal_null:
12578 case token_type::value_string:
12579 case token_type::begin_array:
12580 case token_type::begin_object:
12581 case token_type::end_array:
12582 case token_type::end_object:
12583 case token_type::name_separator:
12584 case token_type::value_separator:
12585 case token_type::parse_error:
12586 case token_type::end_of_input:
12587 case token_type::literal_or_value:
12589 return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read,
12590 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
12607 char_int_type
get()
12610 return current = ia.get_character();
12622 bool get_to(T& dest,
const input_format_t format,
const char* context)
12624 auto new_chars_read = ia.get_elements(&dest);
12625 chars_read += new_chars_read;
12630 sax->parse_error(chars_read,
"<end of file>", parse_error::create(110, chars_read, exception_message(format,
"unexpected end of input", context),
nullptr));
12639 char_int_type get_ignore_noop()
12645 while (current ==
'N');
12650 template<
class NumberType>
12651 static void byte_swap(NumberType& number)
12653 constexpr std::size_t sz =
sizeof(number);
12654#ifdef __cpp_lib_byteswap
12655 if constexpr (sz == 1)
12659 else if constexpr(std::is_integral_v<NumberType>)
12661 number = std::byteswap(number);
12667 auto* ptr =
reinterpret_cast<std::uint8_t*
>(&number);
12668 for (std::size_t i = 0; i < sz / 2; ++i)
12672#ifdef __cpp_lib_byteswap
12692 template<
typename NumberType,
bool InputIsLittleEndian = false>
12693 bool get_number(
const input_format_t format, NumberType& result)
12701 if (is_little_endian != (InputIsLittleEndian || format == input_format_t::bjdata))
12722 template<
typename NumberType>
12723 bool get_string(
const input_format_t format,
12724 const NumberType len,
12727 bool success =
true;
12728 for (NumberType i = 0; i < len; i++)
12736 result.push_back(
static_cast<typename string_t::value_type
>(current));
12755 template<
typename NumberType>
12756 bool get_binary(
const input_format_t format,
12757 const NumberType len,
12760 bool success =
true;
12761 for (NumberType i = 0; i < len; i++)
12769 result.push_back(
static_cast<typename binary_t::value_type
>(current));
12780 bool unexpect_eof(const input_format_t format, const
char* context)
const
12784 return sax->parse_error(chars_read,
"<end of file>",
12785 parse_error::create(110, chars_read, exception_message(format,
"unexpected end of input", context),
nullptr));
12793 std::string get_token_string()
const
12795 std::array<char, 3> cr{{}};
12796 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(current)));
12797 return std::string{cr.data()};
12806 std::string exception_message(
const input_format_t format,
12807 const std::string& detail,
12808 const std::string& context)
const
12810 std::string error_msg =
"syntax error while parsing ";
12814 case input_format_t::cbor:
12815 error_msg +=
"CBOR";
12818 case input_format_t::msgpack:
12819 error_msg +=
"MessagePack";
12822 case input_format_t::ubjson:
12823 error_msg +=
"UBJSON";
12826 case input_format_t::bson:
12827 error_msg +=
"BSON";
12830 case input_format_t::bjdata:
12831 error_msg +=
"BJData";
12834 case input_format_t::json:
12839 return concat(error_msg,
' ', context,
": ", detail);
12846 InputAdapterType ia;
12849 char_int_type current = char_traits<char_type>::eof();
12852 std::size_t chars_read = 0;
12861 json_sax_t* sax =
nullptr;
12864#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ \
12865 make_array<char_int_type>('F', 'H', 'N', 'S', 'T', 'Z', '[', '{')
12867#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ \
12868 make_array<bjd_type>( \
12869 bjd_type{'B', "byte"}, \
12870 bjd_type{'C', "char"}, \
12871 bjd_type{'D', "double"}, \
12872 bjd_type{'I', "int16"}, \
12873 bjd_type{'L', "int64"}, \
12874 bjd_type{'M', "uint64"}, \
12875 bjd_type{'U', "uint8"}, \
12876 bjd_type{'d', "single"}, \
12877 bjd_type{'i', "int8"}, \
12878 bjd_type{'l', "int32"}, \
12879 bjd_type{'m', "uint32"}, \
12880 bjd_type{'u', "uint16"})
12888 using bjd_type = std::pair<char_int_type, string_t>;
12893#undef JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
12894#undef JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
12897#ifndef JSON_HAS_CPP_17
12898 template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX>
12899 constexpr std::size_t binary_reader<BasicJsonType, InputAdapterType, SAX>::npos;
12922#include <functional>
12967template<
typename BasicJsonType>
12969 std::function<bool(
int ,
parse_event_t , BasicJsonType& )>;
12976template<
typename BasicJsonType,
typename InputAdapterType>
12979 using number_integer_t =
typename BasicJsonType::number_integer_t;
12980 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
12981 using number_float_t =
typename BasicJsonType::number_float_t;
12982 using string_t =
typename BasicJsonType::string_t;
12990 const bool allow_exceptions_ =
true,
12991 const bool ignore_comments =
false,
12992 const bool ignore_trailing_commas_ =
false)
12993 : callback(
std::move(cb))
12994 , m_lexer(
std::move(adapter), ignore_comments)
12995 , allow_exceptions(allow_exceptions_)
12996 , ignore_trailing_commas(ignore_trailing_commas_)
13017 sax_parse_internal(&sdp);
13020 if (
strict && (get_token() != token_type::end_of_input))
13023 m_lexer.get_token_string(),
13025 exception_message(token_type::end_of_input,
"value"),
nullptr));
13037 if (result.is_discarded())
13045 sax_parse_internal(&sdp);
13048 if (
strict && (get_token() != token_type::end_of_input))
13051 m_lexer.get_token_string(),
13052 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
13063 result.assert_invariant();
13078 template<
typename SAX>
13083 const bool result = sax_parse_internal(sax);
13086 if (result &&
strict && (get_token() != token_type::end_of_input))
13088 return sax->parse_error(m_lexer.get_position(),
13089 m_lexer.get_token_string(),
13090 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
13097 template<
typename SAX>
13099 bool sax_parse_internal(SAX* sax)
13103 std::vector<bool> states;
13105 bool skip_to_state_evaluation =
false;
13109 if (!skip_to_state_evaluation)
13112 switch (last_token)
13114 case token_type::begin_object:
13122 if (get_token() == token_type::end_object)
13134 return sax->parse_error(m_lexer.get_position(),
13135 m_lexer.get_token_string(),
13136 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
13146 return sax->parse_error(m_lexer.get_position(),
13147 m_lexer.get_token_string(),
13148 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
13152 states.push_back(
false);
13159 case token_type::begin_array:
13167 if (get_token() == token_type::end_array)
13177 states.push_back(
true);
13183 case token_type::value_float:
13185 const auto res = m_lexer.get_number_float();
13189 return sax->parse_error(m_lexer.get_position(),
13190 m_lexer.get_token_string(),
13191 out_of_range::create(406,
concat(
"number overflow parsing '", m_lexer.get_token_string(),
'\''),
nullptr));
13202 case token_type::literal_false:
13211 case token_type::literal_null:
13220 case token_type::literal_true:
13229 case token_type::value_integer:
13238 case token_type::value_string:
13247 case token_type::value_unsigned:
13256 case token_type::parse_error:
13259 return sax->parse_error(m_lexer.get_position(),
13260 m_lexer.get_token_string(),
13261 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized,
"value"),
nullptr));
13263 case token_type::end_of_input:
13267 return sax->parse_error(m_lexer.get_position(),
13268 m_lexer.get_token_string(),
13269 parse_error::create(101, m_lexer.get_position(),
13270 "attempting to parse an empty input; check that your input string or stream contains the expected JSON",
nullptr));
13273 return sax->parse_error(m_lexer.get_position(),
13274 m_lexer.get_token_string(),
13275 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value,
"value"),
nullptr));
13277 case token_type::uninitialized:
13278 case token_type::end_array:
13279 case token_type::end_object:
13280 case token_type::name_separator:
13281 case token_type::value_separator:
13282 case token_type::literal_or_value:
13285 return sax->parse_error(m_lexer.get_position(),
13286 m_lexer.get_token_string(),
13287 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value,
"value"),
nullptr));
13293 skip_to_state_evaluation =
false;
13297 if (states.empty())
13307 if (get_token() == token_type::value_separator)
13313 if (!(ignore_trailing_commas && last_token == token_type::end_array))
13333 skip_to_state_evaluation =
true;
13337 return sax->parse_error(m_lexer.get_position(),
13338 m_lexer.get_token_string(),
13339 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_array,
"array"),
nullptr));
13346 if (get_token() == token_type::value_separator)
13351 if (!(ignore_trailing_commas && last_token == token_type::end_object))
13356 return sax->parse_error(m_lexer.get_position(),
13357 m_lexer.get_token_string(),
13358 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
13369 return sax->parse_error(m_lexer.get_position(),
13370 m_lexer.get_token_string(),
13371 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
13394 skip_to_state_evaluation =
true;
13398 return sax->parse_error(m_lexer.get_position(),
13399 m_lexer.get_token_string(),
13400 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_object,
"object"),
nullptr));
13405 token_type get_token()
13407 return last_token = m_lexer.scan();
13410 std::string exception_message(
const token_type expected,
const std::string& context)
13412 std::string error_msg =
"syntax error ";
13414 if (!context.empty())
13416 error_msg +=
concat(
"while parsing ", context,
' ');
13421 if (last_token == token_type::parse_error)
13423 error_msg +=
concat(m_lexer.get_error_message(),
"; last read: '",
13424 m_lexer.get_token_string(),
'\'');
13428 error_msg +=
concat(
"unexpected ", lexer_t::token_type_name(last_token));
13431 if (expected != token_type::uninitialized)
13433 error_msg +=
concat(
"; expected ", lexer_t::token_type_name(expected));
13441 const parser_callback_t<BasicJsonType> callback =
nullptr;
13443 token_type last_token = token_type::uninitialized;
13447 const bool allow_exceptions =
true;
13449 const bool ignore_trailing_commas =
false;
13501 using difference_type = std::ptrdiff_t;
13502 static constexpr difference_type begin_value = 0;
13503 static constexpr difference_type end_value = begin_value + 1;
13507 difference_type m_it = (std::numeric_limits<std::ptrdiff_t>::min)();
13518 m_it = begin_value;
13530 return m_it == begin_value;
13536 return m_it == end_value;
13541 return lhs.m_it == rhs.m_it;
13546 return lhs.m_it < rhs.m_it;
13551 auto result = *
this;
13558 return lhs.m_it - rhs.m_it;
13569 auto result = *
this;
13582 auto result = *
this;
13639#include <type_traits>
13661template<
typename IteratorType>
class iteration_proxy;
13662template<
typename IteratorType>
class iteration_proxy_value;
13680template<
typename BasicJsonType>
13686 friend other_iter_impl;
13687 friend BasicJsonType;
13691 using object_t =
typename BasicJsonType::object_t;
13692 using array_t =
typename BasicJsonType::array_t;
13695 "iter_impl only accepts (const) basic_json");
13697 static_assert(std::is_base_of<std::bidirectional_iterator_tag, std::bidirectional_iterator_tag>::value
13698 && std::is_base_of<std::bidirectional_iterator_tag, typename std::iterator_traits<typename array_t::iterator>::iterator_category>
::value,
13699 "basic_json iterator assumes array and object type iterators satisfy the LegacyBidirectionalIterator named requirement.");
13714 using pointer =
typename std::conditional<std::is_const<BasicJsonType>::value,
13715 typename BasicJsonType::const_pointer,
13716 typename BasicJsonType::pointer>::type;
13719 typename std::conditional<std::is_const<BasicJsonType>::value,
13720 typename BasicJsonType::const_reference,
13721 typename BasicJsonType::reference>::type;
13738 switch (m_object->m_data.m_type)
13742 m_it.object_iterator =
typename object_t::iterator();
13748 m_it.array_iterator =
typename array_t::iterator();
13785 : m_object(other.m_object),
m_it(other.m_it)
13796 if (&other !=
this)
13798 m_object = other.m_object;
13810 : m_object(other.m_object),
m_it(other.m_it)
13821 m_object = other.m_object;
13831 void set_begin() noexcept
13835 switch (m_object->m_data.m_type)
13839 m_it.object_iterator = m_object->m_data.m_value.object->begin();
13845 m_it.array_iterator = m_object->m_data.m_value.array->begin();
13852 m_it.primitive_iterator.set_end();
13865 m_it.primitive_iterator.set_begin();
13879 switch (m_object->m_data.m_type)
13883 m_it.object_iterator = m_object->m_data.m_value.object->end();
13889 m_it.array_iterator = m_object->m_data.m_value.array->end();
13903 m_it.primitive_iterator.set_end();
13918 switch (m_object->m_data.m_type)
13922 JSON_ASSERT(
m_it.object_iterator != m_object->m_data.m_value.object->end());
13923 return m_it.object_iterator->second;
13928 JSON_ASSERT(
m_it.array_iterator != m_object->m_data.m_value.array->end());
13929 return *
m_it.array_iterator;
13962 switch (m_object->m_data.m_type)
13966 JSON_ASSERT(
m_it.object_iterator != m_object->m_data.m_value.object->end());
13967 return &(
m_it.object_iterator->second);
13972 JSON_ASSERT(
m_it.array_iterator != m_object->m_data.m_value.array->end());
13973 return &*
m_it.array_iterator;
14002 auto result = *
this;
14015 switch (m_object->m_data.m_type)
14019 std::advance(
m_it.object_iterator, 1);
14025 std::advance(
m_it.array_iterator, 1);
14039 ++
m_it.primitive_iterator;
14053 auto result = *
this;
14066 switch (m_object->m_data.m_type)
14070 std::advance(
m_it.object_iterator, -1);
14076 std::advance(
m_it.array_iterator, -1);
14090 --
m_it.primitive_iterator;
14102 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
14112 if (m_object ==
nullptr)
14117 switch (m_object->m_data.m_type)
14120 return (
m_it.object_iterator == other.m_it.object_iterator);
14123 return (
m_it.array_iterator == other.m_it.array_iterator);
14134 return (
m_it.primitive_iterator == other.m_it.primitive_iterator);
14142 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
14161 if (m_object ==
nullptr)
14167 switch (m_object->m_data.m_type)
14173 return (
m_it.array_iterator < other.
m_it.array_iterator);
14184 return (
m_it.primitive_iterator < other.
m_it.primitive_iterator);
14194 return !other.operator < (*this);
14223 switch (m_object->m_data.m_type)
14230 std::advance(
m_it.array_iterator, i);
14244 m_it.primitive_iterator += i;
14267 auto result = *
this;
14289 auto result = *
this;
14302 switch (m_object->m_data.m_type)
14308 return m_it.array_iterator - other.
m_it.array_iterator;
14319 return m_it.primitive_iterator - other.
m_it.primitive_iterator;
14331 switch (m_object->m_data.m_type)
14337 return *std::next(
m_it.array_iterator, n);
14365 const typename object_t::key_type&
key()
const
14371 return m_it.object_iterator->first;
14442template<
typename Base>
14516 auto it = --this->base();
14523 auto it = --this->base();
14524 return it.operator * ();
14544#include <type_traits>
14567 std::is_same<T, void>::value,
14586#include <algorithm>
14614template<
typename RefStringType>
14624 template<
typename T>
14625 struct string_t_helper
14633 using type = StringType;
14638 using string_t =
typename string_t_helper<RefStringType>::type;
14643 : reference_tokens(split(s))
14650 return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
14654 return detail::concat(a,
'/', detail::escape(b));
14680 reference_tokens.insert(reference_tokens.end(),
14681 ptr.reference_tokens.begin(),
14682 ptr.reference_tokens.end());
14698 return *
this /= std::to_string(array_idx);
14746 reference_tokens.pop_back();
14758 return reference_tokens.back();
14765 reference_tokens.push_back(token);
14772 reference_tokens.push_back(std::move(token));
14779 return reference_tokens.empty();
14793 template<
typename BasicJsonType>
14794 static typename BasicJsonType::size_type array_index(
const string_t& s)
14796 using size_type =
typename BasicJsonType::size_type;
14810 const char* p = s.c_str();
14811 char* p_end =
nullptr;
14813 const unsigned long long res = std::strtoull(p, &p_end, 10);
14823 if (res >=
static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))
14828 return static_cast<size_type
>(res);
14832 json_pointer top()
const
14839 json_pointer result = *
this;
14840 result.reference_tokens = {reference_tokens[0]};
14853 template<
typename BasicJsonType>
14854 BasicJsonType& get_and_create(BasicJsonType& j)
const
14860 for (
const auto& reference_token : reference_tokens)
14862 switch (result->type())
14866 if (reference_token ==
"0")
14869 result = &result->operator[](0);
14874 result = &result->operator[](reference_token);
14882 result = &result->operator[](reference_token);
14889 result = &result->operator[](array_index<BasicJsonType>(reference_token));
14933 template<
typename BasicJsonType>
14934 BasicJsonType& get_unchecked(BasicJsonType* ptr)
const
14936 for (
const auto& reference_token : reference_tokens)
14939 if (ptr->is_null())
14943 std::all_of(reference_token.begin(), reference_token.end(),
14944 [](
const unsigned char x)
14946 return std::isdigit(x);
14950 *ptr = (nums || reference_token ==
"-")
14955 switch (ptr->type())
14960 ptr = &ptr->operator[](reference_token);
14966 if (reference_token ==
"-")
14969 ptr = &ptr->operator[](ptr->m_data.m_value.array->size());
14974 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
15001 template<
typename BasicJsonType>
15002 BasicJsonType& get_checked(BasicJsonType* ptr)
const
15004 for (
const auto& reference_token : reference_tokens)
15006 switch (ptr->type())
15011 ptr = &ptr->at(reference_token);
15021 "array index '-' (", std::to_string(ptr->m_data.m_value.array->size()),
15022 ") is out of range"), ptr));
15026 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
15059 template<
typename BasicJsonType>
15060 const BasicJsonType& get_unchecked(
const BasicJsonType* ptr)
const
15062 for (
const auto& reference_token : reference_tokens)
15064 switch (ptr->type())
15069 ptr = &ptr->operator[](reference_token);
15082 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
15108 template<
typename BasicJsonType>
15109 const BasicJsonType& get_checked(
const BasicJsonType* ptr)
const
15111 for (
const auto& reference_token : reference_tokens)
15113 switch (ptr->type())
15118 ptr = &ptr->at(reference_token);
15128 "array index '-' (", std::to_string(ptr->m_data.m_value.array->size()),
15129 ") is out of range"), ptr));
15133 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
15157 template<
typename BasicJsonType>
15158 bool contains(
const BasicJsonType* ptr)
const
15160 for (
const auto& reference_token : reference_tokens)
15162 switch (ptr->type())
15166 if (!ptr->contains(reference_token))
15172 ptr = &ptr->operator[](reference_token);
15183 if (
JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !(
"0" <= reference_token && reference_token <=
"9")))
15195 for (std::size_t i = 1; i < reference_token.size(); i++)
15205 const auto idx = array_index<BasicJsonType>(reference_token);
15206 if (idx >= ptr->size())
15212 ptr = &ptr->operator[](idx);
15246 static std::vector<string_t> split(
const string_t& reference_string)
15248 std::vector<string_t> result;
15251 if (reference_string.empty())
15267 std::size_t slash = reference_string.find_first_of(
'/', 1),
15274 start = (slash == string_t::npos) ? 0 : slash + 1,
15276 slash = reference_string.find_first_of(
'/', start))
15280 auto reference_token = reference_string.substr(start, slash - start);
15283 for (std::size_t pos = reference_token.find_first_of(
'~');
15284 pos != string_t::npos;
15285 pos = reference_token.find_first_of(
'~', pos + 1))
15291 (reference_token[pos + 1] !=
'0' &&
15292 reference_token[pos + 1] !=
'1')))
15300 result.push_back(reference_token);
15314 template<
typename BasicJsonType>
15315 static void flatten(
const string_t& reference_string,
15316 const BasicJsonType& value,
15317 BasicJsonType& result)
15319 switch (
value.type())
15323 if (
value.m_data.m_value.array->empty())
15326 result[reference_string] =
nullptr;
15331 for (std::size_t i = 0; i <
value.m_data.m_value.array->size(); ++i)
15334 value.m_data.m_value.array->operator[](i), result);
15342 if (
value.m_data.m_value.object->empty())
15345 result[reference_string] =
nullptr;
15350 for (
const auto& element : *
value.m_data.m_value.object)
15369 result[reference_string] =
value;
15385 template<
typename BasicJsonType>
15386 static BasicJsonType
15387 unflatten(
const BasicJsonType& value)
15394 BasicJsonType result;
15397 for (
const auto& element : *
value.m_data.m_value.object)
15408 json_pointer(element.first).get_and_create(result) = element.second;
15415 json_pointer<string_t> convert() const&
15417 json_pointer<string_t> result;
15418 result.reference_tokens = reference_tokens;
15422 json_pointer<string_t> convert()&&
15424 json_pointer<string_t> result;
15425 result.reference_tokens = std::move(reference_tokens);
15430#if JSON_HAS_THREE_WAY_COMPARISON
15433 template<
typename RefStringTypeRhs>
15434 bool operator==(
const json_pointer<RefStringTypeRhs>& rhs)
const noexcept
15436 return reference_tokens == rhs.reference_tokens;
15444 return *
this == json_pointer(rhs);
15448 template<
typename RefStringTypeRhs>
15449 std::strong_ordering operator<=>(
const json_pointer<RefStringTypeRhs>& rhs)
const noexcept
15451 return reference_tokens <=> rhs.reference_tokens;
15456 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15458 friend bool operator==(
const json_pointer<RefStringTypeLhs>& lhs,
15459 const json_pointer<RefStringTypeRhs>& rhs)
noexcept;
15463 template<
typename RefStringTypeLhs,
typename StringType>
15465 friend bool operator==(
const json_pointer<RefStringTypeLhs>& lhs,
15466 const StringType& rhs);
15470 template<
typename RefStringTypeRhs,
typename StringType>
15472 friend bool operator==(
const StringType& lhs,
15473 const json_pointer<RefStringTypeRhs>& rhs);
15477 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15479 friend bool operator!=(
const json_pointer<RefStringTypeLhs>& lhs,
15480 const json_pointer<RefStringTypeRhs>& rhs)
noexcept;
15484 template<
typename RefStringTypeLhs,
typename StringType>
15486 friend bool operator!=(
const json_pointer<RefStringTypeLhs>& lhs,
15487 const StringType& rhs);
15491 template<
typename RefStringTypeRhs,
typename StringType>
15493 friend bool operator!=(
const StringType& lhs,
15494 const json_pointer<RefStringTypeRhs>& rhs);
15497 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15499 friend bool operator<(
const json_pointer<RefStringTypeLhs>& lhs,
15500 const json_pointer<RefStringTypeRhs>& rhs)
noexcept;
15505 std::vector<string_t> reference_tokens;
15508#if !JSON_HAS_THREE_WAY_COMPARISON
15510template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15514 return lhs.reference_tokens == rhs.reference_tokens;
15517template<
typename RefStringTypeLhs,
15521 const StringType& rhs)
15526template<
typename RefStringTypeRhs,
15529inline
bool operator==(const StringType& lhs,
15535template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15539 return !(lhs == rhs);
15542template<
typename RefStringTypeLhs,
15546 const StringType& rhs)
15548 return !(lhs == rhs);
15551template<
typename RefStringTypeRhs,
15554inline
bool operator!=(const StringType& lhs,
15557 return !(lhs == rhs);
15560template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15564 return lhs.reference_tokens < rhs.reference_tokens;
15581#include <initializer_list>
15593template<
typename BasicJsonType>
15604 : value_ref(&
value)
15608 : owned_value(init)
15615 : owned_value(
std::forward<Args>(args)...)
15627 if (value_ref ==
nullptr)
15629 return std::move(owned_value);
15636 return value_ref ? *value_ref : owned_value;
15645 mutable value_type owned_value =
nullptr;
15646 value_type
const* value_ref =
nullptr;
15675#include <algorithm>
15701#include <algorithm>
15735template<typename CharType>
15739template<typename CharType, typename AllocatorType =
std::allocator<CharType>>
15755 v.insert(v.end(), s, s + length);
15759 std::vector<CharType, AllocatorType>& v;
15764template<
typename CharType>
15780 stream.write(s,
static_cast<std::streamsize
>(length));
15784 std::basic_ostream<CharType>& stream;
15789template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
15805 str.append(s, length);
15812template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
15816 template<
typename AllocatorType = std::allocator<CharType>>
15861template<
typename BasicJsonType,
typename CharType>
15864 using string_t =
typename BasicJsonType::string_t;
15865 using binary_t =
typename BasicJsonType::binary_t;
15866 using number_float_t =
typename BasicJsonType::number_float_t;
15889 write_bson_object(*j.m_data.m_value.object);
15924 oa->write_character(j.m_data.m_value.boolean
15932 if (j.m_data.m_value.number_integer >= 0)
15937 if (j.m_data.m_value.number_integer <= 0x17)
15939 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15941 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
15944 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15946 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
15949 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
15951 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
15954 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
15959 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
15966 const auto positive_number = -1 - j.m_data.m_value.number_integer;
15967 if (j.m_data.m_value.number_integer >= -24)
15969 write_number(
static_cast<std::uint8_t
>(0x20 + positive_number));
15971 else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
15974 write_number(
static_cast<std::uint8_t
>(positive_number));
15976 else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
15979 write_number(
static_cast<std::uint16_t
>(positive_number));
15981 else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
15984 write_number(
static_cast<std::uint32_t
>(positive_number));
15989 write_number(
static_cast<std::uint64_t
>(positive_number));
15997 if (j.m_data.m_value.number_unsigned <= 0x17)
15999 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_unsigned));
16001 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
16004 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_unsigned));
16006 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
16009 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_unsigned));
16011 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
16014 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_unsigned));
16019 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_unsigned));
16026 if (std::isnan(j.m_data.m_value.number_float))
16033 else if (std::isinf(j.m_data.m_value.number_float))
16050 const auto N = j.m_data.m_value.string->size();
16053 write_number(
static_cast<std::uint8_t
>(0x60 + N));
16055 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16058 write_number(
static_cast<std::uint8_t
>(N));
16060 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16063 write_number(
static_cast<std::uint16_t
>(N));
16065 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16068 write_number(
static_cast<std::uint32_t
>(N));
16071 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
16074 write_number(
static_cast<std::uint64_t
>(N));
16079 oa->write_characters(
16080 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
16081 j.m_data.m_value.string->size());
16088 const auto N = j.m_data.m_value.array->size();
16091 write_number(
static_cast<std::uint8_t
>(0x80 + N));
16093 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16096 write_number(
static_cast<std::uint8_t
>(N));
16098 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16101 write_number(
static_cast<std::uint16_t
>(N));
16103 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16106 write_number(
static_cast<std::uint32_t
>(N));
16109 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
16112 write_number(
static_cast<std::uint64_t
>(N));
16117 for (
const auto& el : *j.m_data.m_value.array)
16126 if (j.m_data.m_value.binary->has_subtype())
16128 if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)())
16130 write_number(
static_cast<std::uint8_t
>(0xd8));
16131 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.binary->subtype()));
16133 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
16135 write_number(
static_cast<std::uint8_t
>(0xd9));
16136 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.binary->subtype()));
16138 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
16140 write_number(
static_cast<std::uint8_t
>(0xda));
16141 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.binary->subtype()));
16143 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
16145 write_number(
static_cast<std::uint8_t
>(0xdb));
16146 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.binary->subtype()));
16151 const auto N = j.m_data.m_value.binary->size();
16154 write_number(
static_cast<std::uint8_t
>(0x40 + N));
16156 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16159 write_number(
static_cast<std::uint8_t
>(N));
16161 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16164 write_number(
static_cast<std::uint16_t
>(N));
16166 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16169 write_number(
static_cast<std::uint32_t
>(N));
16172 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
16175 write_number(
static_cast<std::uint64_t
>(N));
16180 oa->write_characters(
16181 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
16190 const auto N = j.m_data.m_value.object->size();
16193 write_number(
static_cast<std::uint8_t
>(0xA0 + N));
16195 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16198 write_number(
static_cast<std::uint8_t
>(N));
16200 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16203 write_number(
static_cast<std::uint16_t
>(N));
16205 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16208 write_number(
static_cast<std::uint32_t
>(N));
16211 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
16214 write_number(
static_cast<std::uint64_t
>(N));
16219 for (
const auto& el : *j.m_data.m_value.object)
16248 oa->write_character(j.m_data.m_value.boolean
16256 if (j.m_data.m_value.number_integer >= 0)
16261 if (j.m_data.m_value.number_unsigned < 128)
16264 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
16266 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
16270 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
16272 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
16276 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
16278 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
16282 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
16284 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
16288 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
16293 if (j.m_data.m_value.number_integer >= -32)
16296 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.number_integer));
16298 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
16299 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
16303 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.number_integer));
16305 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
16306 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
16310 write_number(
static_cast<std::int16_t
>(j.m_data.m_value.number_integer));
16312 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
16313 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
16317 write_number(
static_cast<std::int32_t
>(j.m_data.m_value.number_integer));
16319 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
16320 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
16324 write_number(
static_cast<std::int64_t
>(j.m_data.m_value.number_integer));
16332 if (j.m_data.m_value.number_unsigned < 128)
16335 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
16337 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
16341 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
16343 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
16347 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
16349 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
16353 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
16355 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
16359 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
16373 const auto N = j.m_data.m_value.string->size();
16377 write_number(
static_cast<std::uint8_t
>(0xA0 | N));
16379 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16383 write_number(
static_cast<std::uint8_t
>(N));
16385 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16389 write_number(
static_cast<std::uint16_t
>(N));
16391 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16395 write_number(
static_cast<std::uint32_t
>(N));
16399 oa->write_characters(
16400 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
16401 j.m_data.m_value.string->size());
16408 const auto N = j.m_data.m_value.array->size();
16412 write_number(
static_cast<std::uint8_t
>(0x90 | N));
16414 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16418 write_number(
static_cast<std::uint16_t
>(N));
16420 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16424 write_number(
static_cast<std::uint32_t
>(N));
16428 for (
const auto& el : *j.m_data.m_value.array)
16439 const bool use_ext = j.m_data.m_value.binary->has_subtype();
16442 const auto N = j.m_data.m_value.binary->size();
16443 if (N <= (std::numeric_limits<std::uint8_t>::max)())
16445 std::uint8_t output_type{};
16452 output_type = 0xD4;
16455 output_type = 0xD5;
16458 output_type = 0xD6;
16461 output_type = 0xD7;
16464 output_type = 0xD8;
16467 output_type = 0xC7;
16475 output_type = 0xC4;
16482 write_number(
static_cast<std::uint8_t
>(N));
16485 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16487 const std::uint8_t output_type = use_ext
16492 write_number(
static_cast<std::uint16_t
>(N));
16494 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16496 const std::uint8_t output_type = use_ext
16501 write_number(
static_cast<std::uint32_t
>(N));
16507 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.binary->subtype()));
16511 oa->write_characters(
16512 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
16521 const auto N = j.m_data.m_value.object->size();
16525 write_number(
static_cast<std::uint8_t
>(0x80 | (N & 0xF)));
16527 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16531 write_number(
static_cast<std::uint16_t
>(N));
16533 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16537 write_number(
static_cast<std::uint32_t
>(N));
16541 for (
const auto& el : *j.m_data.m_value.object)
16564 const bool use_type,
const bool add_prefix =
true,
16584 oa->write_character(j.m_data.m_value.boolean
16593 write_number_with_ubjson_prefix(j.m_data.m_value.number_integer, add_prefix, use_bjdata);
16599 write_number_with_ubjson_prefix(j.m_data.m_value.number_unsigned, add_prefix, use_bjdata);
16605 write_number_with_ubjson_prefix(j.m_data.m_value.number_float, add_prefix, use_bjdata);
16615 write_number_with_ubjson_prefix(j.m_data.m_value.string->size(),
true, use_bjdata);
16616 oa->write_characters(
16617 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
16618 j.m_data.m_value.string->size());
16629 bool prefix_required =
true;
16630 if (use_type && !j.m_data.m_value.array->empty())
16633 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
16634 const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
16635 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
16637 return ubjson_prefix(v, use_bjdata) == first_prefix;
16640 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
16642 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
16644 prefix_required =
false;
16646 oa->write_character(first_prefix);
16653 write_number_with_ubjson_prefix(j.m_data.m_value.array->size(),
true, use_bjdata);
16656 for (
const auto& el : *j.m_data.m_value.array)
16658 write_ubjson(el, use_count, use_type, prefix_required, use_bjdata, bjdata_version);
16676 if (use_type && (bjdata_draft3 || !j.m_data.m_value.binary->empty()))
16680 oa->write_character(bjdata_draft3 ?
'B' :
'U');
16686 write_number_with_ubjson_prefix(j.m_data.m_value.binary->size(),
true, use_bjdata);
16691 oa->write_characters(
16692 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
16693 j.m_data.m_value.binary->size());
16697 for (
size_t i = 0; i < j.m_data.m_value.binary->size(); ++i)
16699 oa->write_character(
to_char_type(bjdata_draft3 ?
'B' :
'U'));
16700 oa->write_character(j.m_data.m_value.binary->data()[i]);
16714 if (use_bjdata && j.m_data.m_value.object->size() == 3 && j.m_data.m_value.object->find(
"_ArrayType_") != j.m_data.m_value.object->end() && j.m_data.m_value.object->find(
"_ArraySize_") != j.m_data.m_value.object->end() && j.m_data.m_value.object->find(
"_ArrayData_") != j.m_data.m_value.object->end())
16716 if (!write_bjdata_ndarray(*j.m_data.m_value.object, use_count, use_type, bjdata_version))
16727 bool prefix_required =
true;
16728 if (use_type && !j.m_data.m_value.object->empty())
16731 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
16732 const bool same_prefix = std::all_of(j.begin(), j.end(),
16733 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
16735 return ubjson_prefix(v, use_bjdata) == first_prefix;
16738 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
16740 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
16742 prefix_required =
false;
16744 oa->write_character(first_prefix);
16751 write_number_with_ubjson_prefix(j.m_data.m_value.object->size(),
true, use_bjdata);
16754 for (
const auto& el : *j.m_data.m_value.object)
16756 write_number_with_ubjson_prefix(el.first.size(),
true, use_bjdata);
16757 oa->write_characters(
16758 reinterpret_cast<const CharType*
>(el.first.c_str()),
16760 write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata, bjdata_version);
16786 static std::size_t calc_bson_entry_header_size(
const string_t& name,
const BasicJsonType& j)
16788 const auto it = name.find(
static_cast<typename string_t::value_type
>(0));
16794 static_cast<void>(j);
16795 return 1ul + name.size() + 1u;
16801 void write_bson_entry_header(
const string_t& name,
16802 const std::uint8_t element_type)
16804 oa->write_character(to_char_type(element_type));
16805 oa->write_characters(
16806 reinterpret_cast<const CharType*
>(name.c_str()),
16813 void write_bson_boolean(
const string_t& name,
16816 write_bson_entry_header(name, 0x08);
16817 oa->write_character(value ? to_char_type(0x01) : to_char_type(0x00));
16823 void write_bson_double(
const string_t& name,
16824 const double value)
16826 write_bson_entry_header(name, 0x01);
16827 write_number<double>(value,
true);
16833 static std::size_t calc_bson_string_size(
const string_t& value)
16835 return sizeof(std::int32_t) +
value.size() + 1ul;
16841 void write_bson_string(
const string_t& name,
16844 write_bson_entry_header(name, 0x02);
16846 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size() + 1ul),
true);
16847 oa->write_characters(
16848 reinterpret_cast<const CharType*
>(
value.c_str()),
16855 void write_bson_null(
const string_t& name)
16857 write_bson_entry_header(name, 0x0A);
16863 static std::size_t calc_bson_integer_size(
const std::int64_t value)
16865 return (std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)()
16866 ?
sizeof(std::int32_t)
16867 :
sizeof(std::int64_t);
16873 void write_bson_integer(
const string_t& name,
16874 const std::int64_t value)
16876 if ((std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)())
16878 write_bson_entry_header(name, 0x10);
16879 write_number<std::int32_t>(
static_cast<std::int32_t
>(value),
true);
16883 write_bson_entry_header(name, 0x12);
16884 write_number<std::int64_t>(
static_cast<std::int64_t
>(value),
true);
16891 static constexpr std::size_t calc_bson_unsigned_size(
const std::uint64_t value)
noexcept
16893 return (value <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16894 ?
sizeof(std::int32_t)
16895 : sizeof(std::int64_t);
16901 void write_bson_unsigned(
const string_t& name,
16902 const BasicJsonType& j)
16904 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16906 write_bson_entry_header(name, 0x10 );
16907 write_number<std::int32_t>(
static_cast<std::int32_t
>(j.m_data.m_value.number_unsigned),
true);
16909 else if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
16911 write_bson_entry_header(name, 0x12 );
16912 write_number<std::int64_t>(
static_cast<std::int64_t
>(j.m_data.m_value.number_unsigned),
true);
16916 write_bson_entry_header(name, 0x11 );
16917 write_number<std::uint64_t>(
static_cast<std::uint64_t
>(j.m_data.m_value.number_unsigned),
true);
16924 void write_bson_object_entry(
const string_t& name,
16925 const typename BasicJsonType::object_t& value)
16927 write_bson_entry_header(name, 0x03);
16928 write_bson_object(value);
16934 static std::size_t calc_bson_array_size(
const typename BasicJsonType::array_t& value)
16936 std::size_t array_index = 0ul;
16938 const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value),
static_cast<std::size_t
>(0), [&array_index](std::size_t result,
const typename BasicJsonType::array_t::value_type & el)
16940 return result + calc_bson_element_size(std::to_string(array_index++), el);
16943 return sizeof(std::int32_t) + embedded_document_size + 1ul;
16949 static std::size_t calc_bson_binary_size(
const typename BasicJsonType::binary_t& value)
16951 return sizeof(std::int32_t) +
value.size() + 1ul;
16957 void write_bson_array(
const string_t& name,
16958 const typename BasicJsonType::array_t& value)
16960 write_bson_entry_header(name, 0x04);
16961 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_array_size(value)),
true);
16963 std::size_t array_index = 0ul;
16965 for (
const auto& el : value)
16967 write_bson_element(std::to_string(array_index++), el);
16970 oa->write_character(to_char_type(0x00));
16976 void write_bson_binary(
const string_t& name,
16979 write_bson_entry_header(name, 0x05);
16981 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size()),
true);
16982 write_number(
value.has_subtype() ?
static_cast<std::uint8_t
>(
value.subtype()) :
static_cast<std::uint8_t
>(0x00));
16984 oa->write_characters(
reinterpret_cast<const CharType*
>(
value.data()),
value.size());
16991 static std::size_t calc_bson_element_size(
const string_t& name,
16992 const BasicJsonType& j)
16994 const auto header_size = calc_bson_entry_header_size(name, j);
16997 case value_t::object:
16998 return header_size + calc_bson_object_size(*j.m_data.m_value.object);
17000 case value_t::array:
17001 return header_size + calc_bson_array_size(*j.m_data.m_value.array);
17003 case value_t::binary:
17004 return header_size + calc_bson_binary_size(*j.m_data.m_value.binary);
17006 case value_t::boolean:
17007 return header_size + 1ul;
17009 case value_t::number_float:
17010 return header_size + 8ul;
17012 case value_t::number_integer:
17013 return header_size + calc_bson_integer_size(j.m_data.m_value.number_integer);
17015 case value_t::number_unsigned:
17016 return header_size + calc_bson_unsigned_size(j.m_data.m_value.number_unsigned);
17018 case value_t::string:
17019 return header_size + calc_bson_string_size(*j.m_data.m_value.string);
17021 case value_t::null:
17022 return header_size + 0ul;
17025 case value_t::discarded:
17039 void write_bson_element(
const string_t& name,
17040 const BasicJsonType& j)
17044 case value_t::object:
17045 return write_bson_object_entry(name, *j.m_data.m_value.object);
17047 case value_t::array:
17048 return write_bson_array(name, *j.m_data.m_value.array);
17050 case value_t::binary:
17051 return write_bson_binary(name, *j.m_data.m_value.binary);
17053 case value_t::boolean:
17054 return write_bson_boolean(name, j.m_data.m_value.boolean);
17056 case value_t::number_float:
17057 return write_bson_double(name, j.m_data.m_value.number_float);
17059 case value_t::number_integer:
17060 return write_bson_integer(name, j.m_data.m_value.number_integer);
17062 case value_t::number_unsigned:
17063 return write_bson_unsigned(name, j);
17065 case value_t::string:
17066 return write_bson_string(name, *j.m_data.m_value.string);
17068 case value_t::null:
17069 return write_bson_null(name);
17072 case value_t::discarded:
17086 static std::size_t calc_bson_object_size(
const typename BasicJsonType::object_t& value)
17088 const std::size_t document_size = std::accumulate(
value.begin(),
value.end(),
static_cast<std::size_t
>(0),
17089 [](
size_t result,
const typename BasicJsonType::object_t::value_type & el)
17091 return result += calc_bson_element_size(el.first, el.second);
17094 return sizeof(std::int32_t) + document_size + 1ul;
17101 void write_bson_object(
const typename BasicJsonType::object_t& value)
17103 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_object_size(value)),
true);
17105 for (
const auto& el : value)
17107 write_bson_element(el.first, el.second);
17110 oa->write_character(to_char_type(0x00));
17117 static constexpr CharType get_cbor_float_prefix(
float )
17119 return to_char_type(0xFA);
17122 static constexpr CharType get_cbor_float_prefix(
double )
17124 return to_char_type(0xFB);
17131 static constexpr CharType get_msgpack_float_prefix(
float )
17133 return to_char_type(0xCA);
17136 static constexpr CharType get_msgpack_float_prefix(
double )
17138 return to_char_type(0xCB);
17146 template<
typename NumberType,
typename std::enable_if<
17147 std::is_floating_point<NumberType>::value,
int>::type = 0>
17148 void write_number_with_ubjson_prefix(
const NumberType n,
17149 const bool add_prefix,
17150 const bool use_bjdata)
17154 oa->write_character(get_ubjson_float_prefix(n));
17156 write_number(n, use_bjdata);
17160 template<
typename NumberType,
typename std::enable_if<
17161 std::is_unsigned<NumberType>::value,
int>::type = 0>
17162 void write_number_with_ubjson_prefix(
const NumberType n,
17163 const bool add_prefix,
17164 const bool use_bjdata)
17166 if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
17170 oa->write_character(to_char_type(
'i'));
17172 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
17174 else if (n <= (std::numeric_limits<std::uint8_t>::max)())
17178 oa->write_character(to_char_type(
'U'));
17180 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
17182 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
17186 oa->write_character(to_char_type(
'I'));
17188 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
17190 else if (use_bjdata && n <=
static_cast<uint64_t
>((std::numeric_limits<uint16_t>::max)()))
17194 oa->write_character(to_char_type(
'u'));
17196 write_number(
static_cast<std::uint16_t
>(n), use_bjdata);
17198 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
17202 oa->write_character(to_char_type(
'l'));
17204 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
17206 else if (use_bjdata && n <=
static_cast<uint64_t
>((std::numeric_limits<uint32_t>::max)()))
17210 oa->write_character(to_char_type(
'm'));
17212 write_number(
static_cast<std::uint32_t
>(n), use_bjdata);
17214 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
17218 oa->write_character(to_char_type(
'L'));
17220 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
17222 else if (use_bjdata && n <= (std::numeric_limits<uint64_t>::max)())
17226 oa->write_character(to_char_type(
'M'));
17228 write_number(
static_cast<std::uint64_t
>(n), use_bjdata);
17234 oa->write_character(to_char_type(
'H'));
17237 const auto number = BasicJsonType(n).dump();
17238 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
17239 for (std::size_t i = 0; i < number.size(); ++i)
17241 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
17247 template <
typename NumberType,
typename std::enable_if <
17248 std::is_signed<NumberType>::value&&
17249 !std::is_floating_point<NumberType>::value,
int >::type = 0 >
17250 void write_number_with_ubjson_prefix(
const NumberType n,
17251 const bool add_prefix,
17252 const bool use_bjdata)
17254 if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)())
17258 oa->write_character(to_char_type(
'i'));
17260 write_number(
static_cast<std::int8_t
>(n), use_bjdata);
17262 else if (
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::max)()))
17266 oa->write_character(to_char_type(
'U'));
17268 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
17270 else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)())
17274 oa->write_character(to_char_type(
'I'));
17276 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
17278 else if (use_bjdata && (
static_cast<std::int64_t
>((std::numeric_limits<std::uint16_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint16_t>::max)())))
17282 oa->write_character(to_char_type(
'u'));
17284 write_number(
static_cast<uint16_t
>(n), use_bjdata);
17286 else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)())
17290 oa->write_character(to_char_type(
'l'));
17292 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
17294 else if (use_bjdata && (
static_cast<std::int64_t
>((std::numeric_limits<std::uint32_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint32_t>::max)())))
17298 oa->write_character(to_char_type(
'm'));
17300 write_number(
static_cast<uint32_t
>(n), use_bjdata);
17302 else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)())
17306 oa->write_character(to_char_type(
'L'));
17308 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
17315 oa->write_character(to_char_type(
'H'));
17318 const auto number = BasicJsonType(n).dump();
17319 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
17320 for (std::size_t i = 0; i < number.size(); ++i)
17322 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
17331 CharType ubjson_prefix(
const BasicJsonType& j,
const bool use_bjdata)
const noexcept
17335 case value_t::null:
17338 case value_t::boolean:
17339 return j.m_data.m_value.boolean ?
'T' :
'F';
17341 case value_t::number_integer:
17343 if ((std::numeric_limits<std::int8_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
17347 if ((std::numeric_limits<std::uint8_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
17351 if ((std::numeric_limits<std::int16_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
17355 if (use_bjdata && ((std::numeric_limits<std::uint16_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)()))
17359 if ((std::numeric_limits<std::int32_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
17363 if (use_bjdata && ((std::numeric_limits<std::uint32_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)()))
17367 if ((std::numeric_limits<std::int64_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
17375 case value_t::number_unsigned:
17377 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
17381 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint8_t>::max)()))
17385 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
17389 if (use_bjdata && j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint16_t>::max)()))
17393 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
17397 if (use_bjdata && j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint32_t>::max)()))
17401 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
17405 if (use_bjdata && j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
17413 case value_t::number_float:
17414 return get_ubjson_float_prefix(j.m_data.m_value.number_float);
17416 case value_t::string:
17419 case value_t::array:
17420 case value_t::binary:
17423 case value_t::object:
17426 case value_t::discarded:
17432 static constexpr CharType get_ubjson_float_prefix(
float )
17437 static constexpr CharType get_ubjson_float_prefix(
double )
17445 bool write_bjdata_ndarray(
const typename BasicJsonType::object_t& value,
const bool use_count,
const bool use_type,
const bjdata_version_t bjdata_version)
17447 std::map<string_t, CharType> bjdtype = {{
"uint8",
'U'}, {
"int8",
'i'}, {
"uint16",
'u'}, {
"int16",
'I'},
17448 {
"uint32",
'm'}, {
"int32",
'l'}, {
"uint64",
'M'}, {
"int64",
'L'}, {
"single",
'd'}, {
"double",
'D'},
17449 {
"char",
'C'}, {
"byte",
'B'}
17454 if (it == bjdtype.end())
17458 CharType dtype = it->second;
17460 key =
"_ArraySize_";
17461 std::size_t len = (
value.at(
key).empty() ? 0 : 1);
17462 for (
const auto& el :
value.at(
key))
17464 len *=
static_cast<std::size_t
>(el.m_data.m_value.number_unsigned);
17467 key =
"_ArrayData_";
17473 oa->write_character(
'[');
17474 oa->write_character(
'$');
17475 oa->write_character(dtype);
17476 oa->write_character(
'#');
17478 key =
"_ArraySize_";
17479 write_ubjson(
value.at(
key), use_count, use_type,
true,
true, bjdata_version);
17481 key =
"_ArrayData_";
17482 if (dtype ==
'U' || dtype ==
'C' || dtype ==
'B')
17484 for (
const auto& el :
value.at(
key))
17486 write_number(
static_cast<std::uint8_t
>(el.m_data.m_value.number_unsigned),
true);
17489 else if (dtype ==
'i')
17491 for (
const auto& el :
value.at(
key))
17493 write_number(
static_cast<std::int8_t
>(el.m_data.m_value.number_integer),
true);
17496 else if (dtype ==
'u')
17498 for (
const auto& el :
value.at(
key))
17500 write_number(
static_cast<std::uint16_t
>(el.m_data.m_value.number_unsigned),
true);
17503 else if (dtype ==
'I')
17505 for (
const auto& el :
value.at(
key))
17507 write_number(
static_cast<std::int16_t
>(el.m_data.m_value.number_integer),
true);
17510 else if (dtype ==
'm')
17512 for (
const auto& el :
value.at(
key))
17514 write_number(
static_cast<std::uint32_t
>(el.m_data.m_value.number_unsigned),
true);
17517 else if (dtype ==
'l')
17519 for (
const auto& el :
value.at(
key))
17521 write_number(
static_cast<std::int32_t
>(el.m_data.m_value.number_integer),
true);
17524 else if (dtype ==
'M')
17526 for (
const auto& el :
value.at(
key))
17528 write_number(
static_cast<std::uint64_t
>(el.m_data.m_value.number_unsigned),
true);
17531 else if (dtype ==
'L')
17533 for (
const auto& el :
value.at(
key))
17535 write_number(
static_cast<std::int64_t
>(el.m_data.m_value.number_integer),
true);
17538 else if (dtype ==
'd')
17540 for (
const auto& el :
value.at(
key))
17542 write_number(
static_cast<float>(el.m_data.m_value.number_float),
true);
17545 else if (dtype ==
'D')
17547 for (
const auto& el :
value.at(
key))
17549 write_number(
static_cast<double>(el.m_data.m_value.number_float),
true);
17572 template<
typename NumberType>
17573 void write_number(
const NumberType n,
const bool OutputIsLittleEndian =
false)
17576 std::array<CharType,
sizeof(NumberType)> vec{};
17577 std::memcpy(vec.data(), &n,
sizeof(NumberType));
17580 if (is_little_endian != OutputIsLittleEndian)
17583 std::reverse(vec.begin(), vec.end());
17586 oa->write_characters(vec.data(),
sizeof(NumberType));
17592#pragma GCC diagnostic push
17593#pragma GCC diagnostic ignored "-Wfloat-equal"
17595 if (!std::isfinite(n) || ((
static_cast<double>(n) >=
static_cast<double>(std::numeric_limits<float>::lowest()) &&
17596 static_cast<double>(n) <=
static_cast<double>((std::numeric_limits<float>::max)()) &&
17597 static_cast<double>(
static_cast<float>(n)) ==
static_cast<double>(n))))
17600 ? get_cbor_float_prefix(
static_cast<float>(n))
17601 : get_msgpack_float_prefix(
static_cast<float>(n)));
17602 write_number(
static_cast<float>(n));
17607 ? get_cbor_float_prefix(n)
17608 : get_msgpack_float_prefix(n));
17612#pragma GCC diagnostic pop
17621 template <
typename C = CharType,
17622 enable_if_t < std::is_signed<C>::value && std::is_signed<char>::value > * =
nullptr >
17625 return *
reinterpret_cast<char*
>(&x);
17628 template <
typename C = CharType,
17629 enable_if_t < std::is_signed<C>::value && std::is_unsigned<char>::value > * =
nullptr >
17639#ifdef JSON_HAS_CPP_26
17640 static_assert(std::is_trivially_copyable<CharType>::value,
"CharType must be trivially copyable");
17641 static_assert(std::is_trivially_default_constructible<CharType>::value,
"CharType must be trivially default constructible");
17643 static_assert(std::is_trivial<CharType>::value,
"CharType must be trivial");
17646 static_assert(
sizeof(std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
17648 std::memcpy(&result, &x,
sizeof(x));
17652 template<
typename C = CharType,
17659 template <
typename InputCharType,
typename C = CharType,
17661 std::is_signed<C>::value &&
17662 std::is_signed<char>::value &&
17663 std::is_same<char, typename std::remove_cv<InputCharType>::type>
::value
17695#include <algorithm>
17705#include <type_traits>
17725#include <type_traits>
17756template<
typename Target,
typename Source>
17759 static_assert(
sizeof(Target) ==
sizeof(Source),
"size mismatch");
17762 std::memcpy(&target, &source,
sizeof(Source));
17773 constexpr diyfp(std::uint64_t f_,
int e_) noexcept :
f(f_),
e(e_) {}
17784 return {x.f - y.f, x.e};
17793 static_assert(
kPrecision == 64,
"internal error");
17818 const std::uint64_t u_lo = x.f & 0xFFFFFFFFu;
17819 const std::uint64_t u_hi = x.f >> 32u;
17820 const std::uint64_t v_lo = y.f & 0xFFFFFFFFu;
17821 const std::uint64_t v_hi = y.f >> 32u;
17823 const std::uint64_t p0 = u_lo * v_lo;
17824 const std::uint64_t p1 = u_lo * v_hi;
17825 const std::uint64_t p2 = u_hi * v_lo;
17826 const std::uint64_t p3 = u_hi * v_hi;
17828 const std::uint64_t p0_hi = p0 >> 32u;
17829 const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
17830 const std::uint64_t p1_hi = p1 >> 32u;
17831 const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
17832 const std::uint64_t p2_hi = p2 >> 32u;
17834 std::uint64_t Q = p0_hi + p1_lo + p2_lo;
17845 Q += std::uint64_t{1} << (64u - 32u - 1u);
17847 const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
17849 return {h, x.e + y.e + 64};
17860 while ((x.f >> 63u) == 0)
17875 const int delta = x.e - target_exponent;
17880 return {x.f << delta, target_exponent};
17897template<
typename FloatType>
17910 static_assert(std::numeric_limits<FloatType>::is_iec559,
17911 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
17913 constexpr int kPrecision = std::numeric_limits<FloatType>::digits;
17914 constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
17915 constexpr int kMinExp = 1 - kBias;
17916 constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1);
17918 using bits_type =
typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type;
17921 const std::uint64_t E = bits >> (kPrecision - 1);
17922 const std::uint64_t F = bits & (kHiddenBit - 1);
17924 const bool is_denormal = E == 0;
17925 const diyfp v = is_denormal
17926 ?
diyfp(F, kMinExp)
17927 :
diyfp(F + kHiddenBit,
static_cast<int>(E) - kBias);
17950 const bool lower_boundary_is_closer = F == 0 && E > 1;
17952 const diyfp m_minus = lower_boundary_is_closer
17953 ?
diyfp((4 * v.
f) - 1, v.
e - 2)
17954 :
diyfp((2 * v.
f) - 1, v.
e - 1);
18089 constexpr int kCachedPowersMinDecExp = -300;
18090 constexpr int kCachedPowersDecStep = 8;
18092 static constexpr std::array<cached_power, 79> kCachedPowers =
18095 { 0xAB70FE17C79AC6CA, -1060, -300 },
18096 { 0xFF77B1FCBEBCDC4F, -1034, -292 },
18097 { 0xBE5691EF416BD60C, -1007, -284 },
18098 { 0x8DD01FAD907FFC3C, -980, -276 },
18099 { 0xD3515C2831559A83, -954, -268 },
18100 { 0x9D71AC8FADA6C9B5, -927, -260 },
18101 { 0xEA9C227723EE8BCB, -901, -252 },
18102 { 0xAECC49914078536D, -874, -244 },
18103 { 0x823C12795DB6CE57, -847, -236 },
18104 { 0xC21094364DFB5637, -821, -228 },
18105 { 0x9096EA6F3848984F, -794, -220 },
18106 { 0xD77485CB25823AC7, -768, -212 },
18107 { 0xA086CFCD97BF97F4, -741, -204 },
18108 { 0xEF340A98172AACE5, -715, -196 },
18109 { 0xB23867FB2A35B28E, -688, -188 },
18110 { 0x84C8D4DFD2C63F3B, -661, -180 },
18111 { 0xC5DD44271AD3CDBA, -635, -172 },
18112 { 0x936B9FCEBB25C996, -608, -164 },
18113 { 0xDBAC6C247D62A584, -582, -156 },
18114 { 0xA3AB66580D5FDAF6, -555, -148 },
18115 { 0xF3E2F893DEC3F126, -529, -140 },
18116 { 0xB5B5ADA8AAFF80B8, -502, -132 },
18117 { 0x87625F056C7C4A8B, -475, -124 },
18118 { 0xC9BCFF6034C13053, -449, -116 },
18119 { 0x964E858C91BA2655, -422, -108 },
18120 { 0xDFF9772470297EBD, -396, -100 },
18121 { 0xA6DFBD9FB8E5B88F, -369, -92 },
18122 { 0xF8A95FCF88747D94, -343, -84 },
18123 { 0xB94470938FA89BCF, -316, -76 },
18124 { 0x8A08F0F8BF0F156B, -289, -68 },
18125 { 0xCDB02555653131B6, -263, -60 },
18126 { 0x993FE2C6D07B7FAC, -236, -52 },
18127 { 0xE45C10C42A2B3B06, -210, -44 },
18128 { 0xAA242499697392D3, -183, -36 },
18129 { 0xFD87B5F28300CA0E, -157, -28 },
18130 { 0xBCE5086492111AEB, -130, -20 },
18131 { 0x8CBCCC096F5088CC, -103, -12 },
18132 { 0xD1B71758E219652C, -77, -4 },
18133 { 0x9C40000000000000, -50, 4 },
18134 { 0xE8D4A51000000000, -24, 12 },
18135 { 0xAD78EBC5AC620000, 3, 20 },
18136 { 0x813F3978F8940984, 30, 28 },
18137 { 0xC097CE7BC90715B3, 56, 36 },
18138 { 0x8F7E32CE7BEA5C70, 83, 44 },
18139 { 0xD5D238A4ABE98068, 109, 52 },
18140 { 0x9F4F2726179A2245, 136, 60 },
18141 { 0xED63A231D4C4FB27, 162, 68 },
18142 { 0xB0DE65388CC8ADA8, 189, 76 },
18143 { 0x83C7088E1AAB65DB, 216, 84 },
18144 { 0xC45D1DF942711D9A, 242, 92 },
18145 { 0x924D692CA61BE758, 269, 100 },
18146 { 0xDA01EE641A708DEA, 295, 108 },
18147 { 0xA26DA3999AEF774A, 322, 116 },
18148 { 0xF209787BB47D6B85, 348, 124 },
18149 { 0xB454E4A179DD1877, 375, 132 },
18150 { 0x865B86925B9BC5C2, 402, 140 },
18151 { 0xC83553C5C8965D3D, 428, 148 },
18152 { 0x952AB45CFA97A0B3, 455, 156 },
18153 { 0xDE469FBD99A05FE3, 481, 164 },
18154 { 0xA59BC234DB398C25, 508, 172 },
18155 { 0xF6C69A72A3989F5C, 534, 180 },
18156 { 0xB7DCBF5354E9BECE, 561, 188 },
18157 { 0x88FCF317F22241E2, 588, 196 },
18158 { 0xCC20CE9BD35C78A5, 614, 204 },
18159 { 0x98165AF37B2153DF, 641, 212 },
18160 { 0xE2A0B5DC971F303A, 667, 220 },
18161 { 0xA8D9D1535CE3B396, 694, 228 },
18162 { 0xFB9B7CD9A4A7443C, 720, 236 },
18163 { 0xBB764C4CA7A44410, 747, 244 },
18164 { 0x8BAB8EEFB6409C1A, 774, 252 },
18165 { 0xD01FEF10A657842C, 800, 260 },
18166 { 0x9B10A4E5E9913129, 827, 268 },
18167 { 0xE7109BFBA19C0C9D, 853, 276 },
18168 { 0xAC2820D9623BF429, 880, 284 },
18169 { 0x80444B5E7AA7CF85, 907, 292 },
18170 { 0xBF21E44003ACDD2D, 933, 300 },
18171 { 0x8E679C2F5E44FF8F, 960, 308 },
18172 { 0xD433179D9C8CB841, 986, 316 },
18173 { 0x9E19DB92B4E31BA9, 1013, 324 },
18183 const int f =
kAlpha - e - 1;
18184 const int k = ((f * 78913) / (1 << 18)) +
static_cast<int>(f > 0);
18186 const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
18188 JSON_ASSERT(
static_cast<std::size_t
>(index) < kCachedPowers.size());
18190 const cached_power cached = kCachedPowers[
static_cast<std::size_t
>(index)];
18204 if (n >= 1000000000)
18206 pow10 = 1000000000;
18210 if (n >= 100000000)
18255inline void grisu2_round(
char* buf,
int len, std::uint64_t dist, std::uint64_t delta,
18256 std::uint64_t rest, std::uint64_t ten_k)
18283 && delta - rest >= ten_k
18284 && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
18299 static_assert(
kAlpha >= -60,
"internal error");
18300 static_assert(
kGamma <= -32,
"internal error");
18317 std::uint64_t delta =
diyfp::sub(M_plus, M_minus).f;
18318 std::uint64_t dist =
diyfp::sub(M_plus, w ).f;
18327 const diyfp one(std::uint64_t{1} << -M_plus.
e, M_plus.
e);
18329 auto p1 =
static_cast<std::uint32_t
>(M_plus.
f >> -one.e);
18330 std::uint64_t p2 = M_plus.
f & (one.f - 1);
18338 std::uint32_t pow10{};
18366 const std::uint32_t d = p1 / pow10;
18367 const std::uint32_t r = p1 % pow10;
18373 buffer[length++] =
static_cast<char>(
'0' + d);
18392 const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
18397 decimal_exponent += n;
18408 const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
18409 grisu2_round(buffer, length, dist, delta, rest, ten_n);
18470 JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
18472 const std::uint64_t d = p2 >> -one.e;
18473 const std::uint64_t r = p2 & (one.f - 1);
18480 buffer[length++] =
static_cast<char>(
'0' + d);
18505 decimal_exponent -= m;
18513 const std::uint64_t ten_m = one.f;
18537inline
void grisu2(
char* buf,
int& len,
int& decimal_exponent,
18554 const diyfp c_minus_k(cached.
f, cached.
e);
18582 const diyfp M_minus(w_minus.
f + 1, w_minus.
e);
18583 const diyfp M_plus (w_plus.
f - 1, w_plus.
e );
18585 decimal_exponent = -cached.
k;
18595template<
typename FloatType>
18600 "internal error: not enough precision");
18652 auto k =
static_cast<std::uint32_t
>(e);
18658 *buf++ =
static_cast<char>(
'0' + k);
18662 *buf++ =
static_cast<char>(
'0' + (k / 10));
18664 *buf++ =
static_cast<char>(
'0' + k);
18668 *buf++ =
static_cast<char>(
'0' + (k / 100));
18670 *buf++ =
static_cast<char>(
'0' + (k / 10));
18672 *buf++ =
static_cast<char>(
'0' + k);
18690 int min_exp,
int max_exp)
18696 const int n = len + decimal_exponent;
18702 if (k <= n && n <= max_exp)
18707 std::memset(buf + k,
'0',
static_cast<size_t>(n) -
static_cast<size_t>(k));
18711 return buf + (
static_cast<size_t>(n) + 2);
18714 if (0 < n && n <= max_exp)
18721 std::memmove(buf + (
static_cast<size_t>(n) + 1), buf + n,
static_cast<size_t>(k) -
static_cast<size_t>(n));
18723 return buf + (
static_cast<size_t>(k) + 1U);
18726 if (min_exp < n && n <= 0)
18731 std::memmove(buf + (2 +
static_cast<size_t>(-n)), buf,
static_cast<size_t>(k));
18734 std::memset(buf + 2,
'0',
static_cast<size_t>(-n));
18735 return buf + (2U +
static_cast<size_t>(-n) +
static_cast<size_t>(k));
18750 std::memmove(buf + 2, buf + 1,
static_cast<size_t>(k) - 1);
18752 buf += 1 +
static_cast<size_t>(k);
18771template<
typename FloatType>
18776 static_cast<void>(last);
18780 if (std::signbit(
value))
18787#pragma GCC diagnostic push
18788#pragma GCC diagnostic ignored "-Wfloat-equal"
18799#pragma GCC diagnostic pop
18802 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10);
18809 int decimal_exponent = 0;
18812 JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
18815 constexpr int kMinExp = -4;
18817 constexpr int kMaxExp = std::numeric_limits<FloatType>::digits10;
18820 JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
18821 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
18860template<
typename BasicJsonType>
18863 using string_t =
typename BasicJsonType::string_t;
18864 using number_float_t =
typename BasicJsonType::number_float_t;
18865 using number_integer_t =
typename BasicJsonType::number_integer_t;
18866 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
18867 using binary_char_t =
typename BasicJsonType::binary_t::value_type;
18868 static constexpr std::uint8_t UTF8_ACCEPT = 0;
18869 static constexpr std::uint8_t UTF8_REJECT = 1;
18880 ,
loc(
std::localeconv())
18918 const bool pretty_print,
18920 const unsigned int indent_step,
18921 const unsigned int current_indent = 0)
18923 switch (val.m_data.m_type)
18927 if (val.m_data.m_value.object->empty())
18929 o->write_characters(
"{}", 2);
18935 o->write_characters(
"{\n", 2);
18938 const auto new_indent = current_indent + indent_step;
18945 auto i = val.m_data.m_value.object->cbegin();
18946 for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i)
18949 o->write_character(
'\"');
18951 o->write_characters(
"\": ", 3);
18953 o->write_characters(
",\n", 2);
18957 JSON_ASSERT(i != val.m_data.m_value.object->cend());
18958 JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend());
18960 o->write_character(
'\"');
18962 o->write_characters(
"\": ", 3);
18965 o->write_character(
'\n');
18966 o->write_characters(
indent_string.c_str(), current_indent);
18967 o->write_character(
'}');
18971 o->write_character(
'{');
18974 auto i = val.m_data.m_value.object->cbegin();
18975 for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i)
18977 o->write_character(
'\"');
18979 o->write_characters(
"\":", 2);
18981 o->write_character(
',');
18985 JSON_ASSERT(i != val.m_data.m_value.object->cend());
18986 JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend());
18987 o->write_character(
'\"');
18989 o->write_characters(
"\":", 2);
18992 o->write_character(
'}');
19000 if (val.m_data.m_value.array->empty())
19002 o->write_characters(
"[]", 2);
19008 o->write_characters(
"[\n", 2);
19011 const auto new_indent = current_indent + indent_step;
19018 for (
auto i = val.m_data.m_value.array->cbegin();
19019 i != val.m_data.m_value.array->cend() - 1; ++i)
19023 o->write_characters(
",\n", 2);
19029 dump(val.m_data.m_value.array->back(),
true,
ensure_ascii, indent_step, new_indent);
19031 o->write_character(
'\n');
19032 o->write_characters(
indent_string.c_str(), current_indent);
19033 o->write_character(
']');
19037 o->write_character(
'[');
19040 for (
auto i = val.m_data.m_value.array->cbegin();
19041 i != val.m_data.m_value.array->cend() - 1; ++i)
19044 o->write_character(
',');
19049 dump(val.m_data.m_value.array->back(),
false,
ensure_ascii, indent_step, current_indent);
19051 o->write_character(
']');
19059 o->write_character(
'\"');
19060 dump_escaped(*val.m_data.m_value.string,
ensure_ascii);
19061 o->write_character(
'\"');
19069 o->write_characters(
"{\n", 2);
19072 const auto new_indent = current_indent + indent_step;
19080 o->write_characters(
"\"bytes\": [", 10);
19082 if (!val.m_data.m_value.binary->empty())
19084 for (
auto i = val.m_data.m_value.binary->cbegin();
19085 i != val.m_data.m_value.binary->cend() - 1; ++i)
19088 o->write_characters(
", ", 2);
19090 dump_integer(val.m_data.m_value.binary->back());
19093 o->write_characters(
"],\n", 3);
19096 o->write_characters(
"\"subtype\": ", 11);
19097 if (val.m_data.m_value.binary->has_subtype())
19099 dump_integer(val.m_data.m_value.binary->subtype());
19103 o->write_characters(
"null", 4);
19105 o->write_character(
'\n');
19106 o->write_characters(
indent_string.c_str(), current_indent);
19107 o->write_character(
'}');
19111 o->write_characters(
"{\"bytes\":[", 10);
19113 if (!val.m_data.m_value.binary->empty())
19115 for (
auto i = val.m_data.m_value.binary->cbegin();
19116 i != val.m_data.m_value.binary->cend() - 1; ++i)
19119 o->write_character(
',');
19121 dump_integer(val.m_data.m_value.binary->back());
19124 o->write_characters(
"],\"subtype\":", 12);
19125 if (val.m_data.m_value.binary->has_subtype())
19127 dump_integer(val.m_data.m_value.binary->subtype());
19128 o->write_character(
'}');
19132 o->write_characters(
"null}", 5);
19140 if (val.m_data.m_value.boolean)
19142 o->write_characters(
"true", 4);
19146 o->write_characters(
"false", 5);
19153 dump_integer(val.m_data.m_value.number_integer);
19159 dump_integer(val.m_data.m_value.number_unsigned);
19165 dump_float(val.m_data.m_value.number_float);
19171 o->write_characters(
"<discarded>", 11);
19177 o->write_characters(
"null", 4);
19203 std::uint32_t codepoint{};
19211 for (std::size_t i = 0; i < s.size(); ++i)
19213 const auto byte =
static_cast<std::uint8_t
>(s[i]);
19215 switch (decode(
state, codepoint,
byte))
19274 if ((codepoint <= 0x1F) || (
ensure_ascii && (codepoint >= 0x7F)))
19276 if (codepoint <= 0xFFFF)
19280 static_cast<std::uint16_t
>(codepoint)));
19286 static_cast<void>((std::snprintf)(
string_buffer.data() +
bytes, 13,
"\\u%04x\\u%04x",
19287 static_cast<std::uint16_t
>(0xD7C0u + (codepoint >> 10u)),
19288 static_cast<std::uint16_t
>(0xDC00u + (codepoint & 0x3FFu))));
19376 state = UTF8_ACCEPT;
19432 o->write_characters(
"\\ufffd", 6);
19436 o->write_characters(
"\xEF\xBF\xBD", 3);
19456 unsigned int count_digits(number_unsigned_t x)
noexcept
19458 unsigned int n_digits = 1;
19467 return n_digits + 1;
19471 return n_digits + 2;
19475 return n_digits + 3;
19487 static std::string hex_bytes(std::uint8_t
byte)
19489 std::string result =
"FF";
19490 constexpr const char* nibble_to_hex =
"0123456789ABCDEF";
19491 result[0] = nibble_to_hex[
byte / 16];
19492 result[1] = nibble_to_hex[
byte % 16];
19497 template <typename NumberType, enable_if_t<std::is_signed<NumberType>::value,
int> = 0>
19498 bool is_negative_number(NumberType x)
19503 template < typename NumberType, enable_if_t <std::is_unsigned<NumberType>::value,
int > = 0 >
19504 bool is_negative_number(NumberType )
19519 std::is_integral<NumberType>::value ||
19520 std::is_same<NumberType, number_unsigned_t>::value ||
19521 std::is_same<NumberType, number_integer_t>::value ||
19522 std::is_same<NumberType, binary_char_t>::value,
19524 void dump_integer(NumberType x)
19526 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
19529 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}}, {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}},
19530 {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}}, {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}},
19531 {{
'2',
'0'}}, {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}}, {{
'2',
'8'}}, {{
'2',
'9'}},
19532 {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}}, {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}},
19533 {{
'4',
'0'}}, {{
'4',
'1'}}, {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}}, {{
'4',
'9'}},
19534 {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}}, {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}},
19535 {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}}, {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
19536 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}}, {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}},
19537 {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}}, {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}},
19538 {{
'9',
'0'}}, {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}}, {{
'9',
'8'}}, {{
'9',
'9'}},
19545 o->write_character(
'0');
19550 auto buffer_ptr = number_buffer.begin();
19552 number_unsigned_t abs_value;
19554 unsigned int n_chars{};
19556 if (is_negative_number(x))
19559 abs_value = remove_sign(
static_cast<number_integer_t
>(x));
19562 n_chars = 1 + count_digits(abs_value);
19566 abs_value =
static_cast<number_unsigned_t
>(x);
19567 n_chars = count_digits(abs_value);
19575 buffer_ptr +=
static_cast<typename decltype(number_buffer)::difference_type
>(n_chars);
19579 while (abs_value >= 100)
19581 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
19583 *(--buffer_ptr) = digits_to_99[digits_index][1];
19584 *(--buffer_ptr) = digits_to_99[digits_index][0];
19587 if (abs_value >= 10)
19589 const auto digits_index =
static_cast<unsigned>(abs_value);
19590 *(--buffer_ptr) = digits_to_99[digits_index][1];
19591 *(--buffer_ptr) = digits_to_99[digits_index][0];
19595 *(--buffer_ptr) =
static_cast<char>(
'0' + abs_value);
19598 o->write_characters(number_buffer.data(), n_chars);
19609 void dump_float(number_float_t x)
19612 if (!std::isfinite(x))
19614 o->write_characters(
"null", 4);
19623 static constexpr bool is_ieee_single_or_double
19624 = (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 24 && std::numeric_limits<number_float_t>::max_exponent == 128) ||
19625 (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 53 && std::numeric_limits<number_float_t>::max_exponent == 1024);
19627 dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
19630 void dump_float(number_float_t x, std::true_type )
19632 auto* begin = number_buffer.data();
19633 auto* end = ::nlohmann::detail::to_chars(begin, begin + number_buffer.size(), x);
19635 o->write_characters(begin,
static_cast<size_t>(end - begin));
19638 void dump_float(number_float_t x, std::false_type )
19641 static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
19645 std::ptrdiff_t len = (std::snprintf)(number_buffer.data(), number_buffer.size(),
"%.*g", d, x);
19650 JSON_ASSERT(
static_cast<std::size_t
>(len) < number_buffer.size());
19653 if (thousands_sep !=
'\0')
19656 const auto end = std::remove(number_buffer.begin(), number_buffer.begin() + len, thousands_sep);
19657 std::fill(end, number_buffer.end(),
'\0');
19658 JSON_ASSERT((end - number_buffer.begin()) <= len);
19659 len = (end - number_buffer.begin());
19663 if (decimal_point !=
'\0' && decimal_point !=
'.')
19666 const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
19667 if (dec_pos != number_buffer.end())
19673 o->write_characters(number_buffer.data(),
static_cast<std::size_t
>(len));
19676 const bool value_is_int_like =
19677 std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1,
19680 return c ==
'.' || c ==
'e';
19683 if (value_is_int_like)
19685 o->write_characters(
".0", 2);
19710 static std::uint8_t decode(std::uint8_t& state, std::uint32_t& codep,
const std::uint8_t
byte)
noexcept
19712 static const std::array<std::uint8_t, 400> utf8d =
19715 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
19716 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
19717 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
19718 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
19719 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
19720 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
19721 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
19722 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
19723 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
19724 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
19725 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1,
19726 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
19727 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1,
19728 1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
19733 const std::uint8_t type = utf8d[byte];
19735 codep = (state != UTF8_ACCEPT)
19736 ? (
byte & 0x3fu) | (codep << 6u)
19737 : (0xFFu >> type) & (byte);
19739 const std::size_t index = 256u + (
static_cast<size_t>(state) * 16u) +
static_cast<size_t>(type);
19741 state = utf8d[index];
19750 number_unsigned_t remove_sign(number_unsigned_t x)
19765 number_unsigned_t remove_sign(number_integer_t x)
noexcept
19767 JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)());
19768 return static_cast<number_unsigned_t
>(-(x + 1)) + 1;
19773 output_adapter_t<char> o =
nullptr;
19815#include <functional>
19816#include <initializer_list>
19819#include <stdexcept>
19820#include <type_traits>
19833template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
19834 class Allocator = std::allocator<std::pair<const Key, T>>>
19839 using Container = std::vector<std::pair<const Key, T>, Allocator>;
19844#ifdef JSON_HAS_CPP_14
19854 template <
class It>
19857 ordered_map(std::initializer_list<value_type> init,
const Allocator& alloc = Allocator() )
19862 for (
auto it = this->begin(); it != this->end(); ++it)
19864 if (m_compare(it->first, key))
19866 return {it,
false};
19869 Container::emplace_back(key, std::forward<T>(t));
19870 return {std::prev(this->end()),
true};
19875 std::pair<iterator, bool>
emplace(KeyType && key, T && t)
19877 for (
auto it = this->begin(); it != this->end(); ++it)
19879 if (m_compare(it->first, key))
19881 return {it,
false};
19884 Container::emplace_back(std::forward<KeyType>(key), std::forward<T>(t));
19885 return {std::prev(this->end()),
true};
19890 return emplace(key, T{}).first->second;
19897 return emplace(std::forward<KeyType>(key), T{}).first->second;
19909 return at(std::forward<KeyType>(key));
19914 for (
auto it = this->begin(); it != this->end(); ++it)
19916 if (m_compare(it->first, key))
19922 JSON_THROW(std::out_of_range(
"key not found"));
19929 for (
auto it = this->begin(); it != this->end(); ++it)
19931 if (m_compare(it->first, key))
19937 JSON_THROW(std::out_of_range(
"key not found"));
19942 for (
auto it = this->begin(); it != this->end(); ++it)
19944 if (m_compare(it->first, key))
19950 JSON_THROW(std::out_of_range(
"key not found"));
19955 const T &
at(KeyType && key)
const
19957 for (
auto it = this->begin(); it != this->end(); ++it)
19959 if (m_compare(it->first, key))
19965 JSON_THROW(std::out_of_range(
"key not found"));
19970 for (
auto it = this->begin(); it != this->end(); ++it)
19972 if (m_compare(it->first, key))
19975 for (
auto next = it; ++next != this->end(); ++it)
19980 Container::pop_back();
19991 for (
auto it = this->begin(); it != this->end(); ++it)
19993 if (m_compare(it->first, key))
19996 for (
auto next = it; ++next != this->end(); ++it)
20001 Container::pop_back();
20010 return erase(pos, std::next(pos));
20020 const auto elements_affected = std::distance(first, last);
20021 const auto offset = std::distance(Container::begin(), first);
20043 for (
auto it = first; std::next(it, elements_affected) != Container::end(); ++it)
20046 new (&*it)
value_type{std::move(*std::next(it, elements_affected))};
20054 Container::resize(this->size() -
static_cast<size_type>(elements_affected));
20063 return Container::begin() + offset;
20068 for (
auto it = this->begin(); it != this->end(); ++it)
20070 if (m_compare(it->first, key))
20082 for (
auto it = this->begin(); it != this->end(); ++it)
20084 if (m_compare(it->first, key))
20094 for (
auto it = this->begin(); it != this->end(); ++it)
20096 if (m_compare(it->first, key))
20101 return Container::end();
20108 for (
auto it = this->begin(); it != this->end(); ++it)
20110 if (m_compare(it->first, key))
20115 return Container::end();
20120 for (
auto it = this->begin(); it != this->end(); ++it)
20122 if (m_compare(it->first, key))
20127 return Container::end();
20132 return emplace(value.first, std::move(value.second));
20137 for (
auto it = this->begin(); it != this->end(); ++it)
20139 if (m_compare(it->first, value.first))
20141 return {it,
false};
20144 Container::push_back(value);
20145 return {--this->end(),
true};
20148 template<
typename InputIt>
20149 using require_input_iter =
typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
20150 std::input_iterator_tag>::value>::type;
20152 template<
typename InputIt,
typename = require_input_iter<InputIt>>
20155 for (
auto it = first; it != last; ++it)
20168#if defined(JSON_HAS_CPP_17)
20169 #if JSON_HAS_STATIC_RTTI
20172 #include <string_view>
20202 :
public ::nlohmann::detail::json_base_class<CustomBaseClass>
20208 friend class ::nlohmann::json_pointer;
20212 template<
typename BasicJsonType,
typename InputType>
20213 friend class ::nlohmann::detail::parser;
20214 friend ::nlohmann::detail::serializer<basic_json>;
20215 template<
typename BasicJsonType>
20216 friend class ::nlohmann::detail::iter_impl;
20217 template<
typename BasicJsonType,
typename CharType>
20218 friend class ::nlohmann::detail::binary_writer;
20219 template<
typename BasicJsonType,
typename InputType,
typename SAX>
20220 friend class ::nlohmann::detail::binary_reader;
20221 template<
typename BasicJsonType,
typename InputAdapterType>
20222 friend class ::nlohmann::detail::json_sax_dom_parser;
20223 template<
typename BasicJsonType,
typename InputAdapterType>
20224 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
20225 friend class ::nlohmann::detail::exception;
20229 using json_base_class_t = ::nlohmann::detail::json_base_class<CustomBaseClass>;
20233 using lexer = ::nlohmann::detail::lexer_base<basic_json>;
20235 template<
typename InputAdapterType>
20236 static ::nlohmann::detail::parser<basic_json, InputAdapterType>
parser(
20237 InputAdapterType adapter,
20239 const bool allow_exceptions =
true,
20240 const bool ignore_comments =
false,
20241 const bool ignore_trailing_commas =
false
20244 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
20245 std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas);
20249 using primitive_iterator_t = ::nlohmann::detail::primitive_iterator_t;
20250 template<
typename BasicJsonType>
20251 using internal_iterator = ::nlohmann::detail::internal_iterator<BasicJsonType>;
20252 template<
typename BasicJsonType>
20253 using iter_impl = ::nlohmann::detail::iter_impl<BasicJsonType>;
20254 template<
typename Iterator>
20255 using iteration_proxy = ::nlohmann::detail::iteration_proxy<Iterator>;
20256 template<
typename Base>
using json_reverse_iterator = ::nlohmann::detail::json_reverse_iterator<Base>;
20258 template<
typename CharType>
20259 using output_adapter_t = ::nlohmann::detail::output_adapter_t<CharType>;
20261 template<
typename InputType>
20262 using binary_reader = ::nlohmann::detail::binary_reader<basic_json, InputType>;
20263 template<
typename CharType>
using binary_writer = ::nlohmann::detail::binary_writer<basic_json, CharType>;
20266 using serializer = ::nlohmann::detail::serializer<basic_json>;
20272 template<
typename T,
typename SFINAE>
20330 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
20332 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
20359 result[
"copyright"] =
"(C) 2013-2025 Niels Lohmann";
20360 result[
"name"] =
"JSON for Modern C++";
20361 result[
"url"] =
"https://github.com/nlohmann/json";
20362 result[
"version"][
"string"] =
20371 result[
"platform"] =
"win32";
20372#elif defined __linux__
20373 result[
"platform"] =
"linux";
20374#elif defined __APPLE__
20375 result[
"platform"] =
"apple";
20376#elif defined __unix__
20377 result[
"platform"] =
"unix";
20379 result[
"platform"] =
"unknown";
20382#if defined(__ICC) || defined(__INTEL_COMPILER)
20383 result[
"compiler"] = {{
"family",
"icc"}, {
"version", __INTEL_COMPILER}};
20384#elif defined(__clang__)
20385 result[
"compiler"] = {{
"family",
"clang"}, {
"version", __clang_version__}};
20386#elif defined(__GNUC__) || defined(__GNUG__)
20387 result[
"compiler"] = {{
"family",
"gcc"}, {
"version",
detail::concat(
20388 std::to_string(__GNUC__),
'.',
20389 std::to_string(__GNUC_MINOR__),
'.',
20390 std::to_string(__GNUC_PATCHLEVEL__))
20393#elif defined(__HP_cc) || defined(__HP_aCC)
20394 result[
"compiler"] =
"hp"
20395#elif defined(__IBMCPP__)
20396 result[
"compiler"] = {{
"family",
"ilecpp"}, {
"version", __IBMCPP__}};
20397#elif defined(_MSC_VER)
20398 result[
"compiler"] = {{
"family",
"msvc"}, {
"version", _MSC_VER}};
20399#elif defined(__PGI)
20400 result[
"compiler"] = {{
"family",
"pgcpp"}, {
"version", __PGI}};
20401#elif defined(__SUNPRO_CC)
20402 result[
"compiler"] = {{
"family",
"sunpro"}, {
"version", __SUNPRO_CC}};
20404 result[
"compiler"] = {{
"family",
"unknown"}, {
"version",
"unknown"}};
20407#if defined(_MSVC_LANG)
20408 result[
"compiler"][
"c++"] = std::to_string(_MSVC_LANG);
20409#elif defined(__cplusplus)
20410 result[
"compiler"][
"c++"] = std::to_string(__cplusplus);
20412 result[
"compiler"][
"c++"] =
"unknown";
20430#if defined(JSON_HAS_CPP_14)
20433 using default_object_comparator_t = std::less<>;
20443 AllocatorType<std::pair<
const StringType,
20448 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
20472 using binary_t = nlohmann::byte_container_with_subtype<BinaryType>;
20483 template<
typename T,
typename... Args>
20485 static T* create(Args&& ... args)
20487 AllocatorType<T> alloc;
20488 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
20490 auto deleter = [&](T * obj)
20492 AllocatorTraits::deallocate(alloc, obj, 1);
20494 std::unique_ptr<T,
decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
20495 AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...);
20497 return obj.release();
20543 number_integer_t number_integer;
20545 number_unsigned_t number_unsigned;
20547 number_float_t number_float;
20550 json_value() =
default;
20552 json_value(boolean_t v) noexcept : boolean(v) {}
20558 json_value(number_float_t v) noexcept :
number_float(v) {}
20560 json_value(value_t t)
20564 case value_t::object:
20566 object = create<object_t>();
20570 case value_t::array:
20572 array = create<array_t>();
20576 case value_t::string:
20578 string = create<string_t>(
"");
20582 case value_t::binary:
20584 binary = create<binary_t>();
20588 case value_t::boolean:
20590 boolean =
static_cast<boolean_t
>(
false);
20594 case value_t::number_integer:
20600 case value_t::number_unsigned:
20606 case value_t::number_float:
20612 case value_t::null:
20618 case value_t::discarded:
20624 JSON_THROW(other_error::create(500,
"961c151d2e87f2686a955a9be24d316f1362bf21 3.12.0",
nullptr));
20632 json_value(
const string_t& value) :
string(create<string_t>(
value)) {}
20635 json_value(string_t&& value) :
string(create<string_t>(std::move(
value))) {}
20638 json_value(
const object_t& value) :
object(create<object_t>(
value)) {}
20641 json_value(object_t&& value) :
object(create<object_t>(std::move(
value))) {}
20644 json_value(
const array_t& value) :
array(create<array_t>(
value)) {}
20647 json_value(array_t&& value) :
array(create<array_t>(std::move(
value))) {}
20650 json_value(
const typename binary_t::container_type& value) :
binary(create<binary_t>(
value)) {}
20653 json_value(
typename binary_t::container_type&& value) :
binary(create<binary_t>(std::move(
value))) {}
20656 json_value(
const binary_t& value) :
binary(create<binary_t>(
value)) {}
20659 json_value(binary_t&& value) :
binary(create<binary_t>(std::move(
value))) {}
20661 void destroy(value_t t)
20664 (t == value_t::object &&
object ==
nullptr) ||
20665 (t == value_t::array && array ==
nullptr) ||
20666 (t == value_t::string &&
string ==
nullptr) ||
20667 (t == value_t::binary && binary ==
nullptr)
20673 if (t == value_t::array || t == value_t::object)
20676 std::vector<basic_json> stack;
20679 if (t == value_t::array)
20681 stack.reserve(
array->size());
20682 std::move(
array->begin(),
array->end(), std::back_inserter(stack));
20686 stack.reserve(
object->size());
20687 for (
auto&& it : *
object)
20689 stack.push_back(std::move(it.second));
20693 while (!stack.empty())
20696 basic_json current_item(std::move(stack.back()));
20701 if (current_item.is_array())
20703 std::move(current_item.m_data.m_value.array->begin(), current_item.m_data.m_value.array->end(), std::back_inserter(stack));
20705 current_item.m_data.m_value.array->clear();
20707 else if (current_item.is_object())
20709 for (
auto&& it : *current_item.m_data.m_value.object)
20711 stack.push_back(std::move(it.second));
20714 current_item.m_data.m_value.object->clear();
20724 case value_t::object:
20726 AllocatorType<object_t> alloc;
20727 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
object);
20728 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
object, 1);
20732 case value_t::array:
20734 AllocatorType<array_t> alloc;
20735 std::allocator_traits<
decltype(alloc)>::destroy(alloc, array);
20736 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, array, 1);
20740 case value_t::string:
20742 AllocatorType<string_t> alloc;
20743 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
string);
20744 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
string, 1);
20748 case value_t::binary:
20750 AllocatorType<binary_t> alloc;
20751 std::allocator_traits<
decltype(alloc)>::destroy(alloc, binary);
20752 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, binary, 1);
20756 case value_t::null:
20757 case value_t::boolean:
20758 case value_t::number_integer:
20759 case value_t::number_unsigned:
20760 case value_t::number_float:
20761 case value_t::discarded:
20789 void assert_invariant(
bool check_parents =
true) const noexcept
20791 JSON_ASSERT(m_data.m_type != value_t::object || m_data.m_value.object !=
nullptr);
20792 JSON_ASSERT(m_data.m_type != value_t::array || m_data.m_value.array !=
nullptr);
20793 JSON_ASSERT(m_data.m_type != value_t::string || m_data.m_value.string !=
nullptr);
20794 JSON_ASSERT(m_data.m_type != value_t::binary || m_data.m_value.binary !=
nullptr);
20796#if JSON_DIAGNOSTICS
20800 JSON_ASSERT(!check_parents || !is_structured() || std::all_of(begin(), end(), [
this](
const basic_json & j)
20802 return j.m_parent ==
this;
20807 static_cast<void>(check_parents);
20812#if JSON_DIAGNOSTICS
20813 switch (m_data.m_type)
20815 case value_t::array:
20817 for (
auto& element : *m_data.m_value.array)
20819 element.m_parent =
this;
20824 case value_t::object:
20826 for (
auto& element : *m_data.m_value.object)
20828 element.second.m_parent =
this;
20833 case value_t::null:
20834 case value_t::string:
20835 case value_t::boolean:
20836 case value_t::number_integer:
20837 case value_t::number_unsigned:
20838 case value_t::number_float:
20839 case value_t::binary:
20840 case value_t::discarded:
20847 iterator set_parents(iterator it,
typename iterator::difference_type count_set_parents)
20849#if JSON_DIAGNOSTICS
20850 for (
typename iterator::difference_type i = 0; i < count_set_parents; ++i)
20852 (it + i)->m_parent =
this;
20855 static_cast<void>(count_set_parents);
20862#if JSON_DIAGNOSTICS
20877#ifdef JSON_HEDLEY_MSVC_VERSION
20878#pragma warning(push )
20879#pragma warning(disable : 4127)
20886#ifdef JSON_HEDLEY_MSVC_VERSION
20887#pragma warning( pop )
20892 static_cast<void>(j);
20893 static_cast<void>(old_capacity);
20925 assert_invariant();
20933 assert_invariant();
20938 template <
typename CompatibleType,
20943 JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
20944 std::forward<CompatibleType>(val))))
20946 JSONSerializer<U>::to_json(*
this, std::forward<CompatibleType>(val));
20948 assert_invariant();
20953 template <
typename BasicJsonType,
20957#if JSON_DIAGNOSTIC_POSITIONS
20958 : start_position(val.start_pos()),
20959 end_position(val.end_pos())
20962 using other_boolean_t =
typename BasicJsonType::boolean_t;
20963 using other_number_float_t =
typename BasicJsonType::number_float_t;
20964 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
20965 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
20966 using other_string_t =
typename BasicJsonType::string_t;
20967 using other_object_t =
typename BasicJsonType::object_t;
20968 using other_array_t =
typename BasicJsonType::array_t;
20969 using other_binary_t =
typename BasicJsonType::binary_t;
20971 switch (val.type())
20973 case value_t::boolean:
20976 case value_t::number_float:
20979 case value_t::number_integer:
20982 case value_t::number_unsigned:
20985 case value_t::string:
20988 case value_t::object:
20991 case value_t::array:
20994 case value_t::binary:
20997 case value_t::null:
21000 case value_t::discarded:
21001 m_data.m_type = value_t::discarded;
21009 assert_invariant();
21015 bool type_deduction =
true,
21016 value_t manual_type = value_t::array)
21020 bool is_an_object = std::all_of(init.begin(), init.end(),
21026 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[static_cast<size_type>(0)].is_string();
21030 if (!type_deduction)
21033 if (manual_type == value_t::array)
21035 is_an_object =
false;
21048 m_data.m_type = value_t::object;
21049 m_data.m_value = value_t::object;
21051 for (
auto& element_ref : init)
21054 m_data.m_value.object->emplace(
21055 std::move(*((*element.m_data.m_value.array)[0].m_data.m_value.string)),
21056 std::move((*element.m_data.m_value.array)[1]));
21062 m_data.m_type = value_t::array;
21063 m_data.m_value.array = create<array_t>(init.begin(), init.end());
21067 assert_invariant();
21076 res.m_data.m_type = value_t::binary;
21077 res.m_data.m_value = init;
21084 static basic_json binary(
const typename binary_t::container_type& init,
typename binary_t::subtype_type subtype)
21087 res.m_data.m_type = value_t::binary;
21088 res.m_data.m_value =
binary_t(init, subtype);
21098 res.m_data.m_type = value_t::binary;
21099 res.m_data.m_value = std::move(init);
21106 static basic_json binary(
typename binary_t::container_type&& init,
typename binary_t::subtype_type subtype)
21109 res.m_data.m_type = value_t::binary;
21110 res.m_data.m_value =
binary_t(std::move(init), subtype);
21119 return basic_json(init,
false, value_t::array);
21127 return basic_json(init,
false, value_t::object);
21136 assert_invariant();
21141 template <
class InputIT,
typename std::enable_if <
21142 std::is_same<InputIT, typename basic_json_t::iterator>::value ||
21143 std::is_same<InputIT, typename basic_json_t::const_iterator>::value,
int >::type = 0 >
21156 m_data.m_type = first.m_object->m_data.m_type;
21161 case value_t::boolean:
21162 case value_t::number_float:
21163 case value_t::number_integer:
21164 case value_t::number_unsigned:
21165 case value_t::string:
21168 || !last.m_it.primitive_iterator.is_end()))
21175 case value_t::null:
21176 case value_t::object:
21177 case value_t::array:
21178 case value_t::binary:
21179 case value_t::discarded:
21186 case value_t::number_integer:
21188 m_data.m_value.number_integer = first.m_object->m_data.m_value.number_integer;
21192 case value_t::number_unsigned:
21194 m_data.m_value.number_unsigned = first.m_object->m_data.m_value.number_unsigned;
21198 case value_t::number_float:
21200 m_data.m_value.number_float = first.m_object->m_data.m_value.number_float;
21204 case value_t::boolean:
21206 m_data.m_value.boolean = first.m_object->m_data.m_value.boolean;
21210 case value_t::string:
21212 m_data.m_value = *first.m_object->m_data.m_value.string;
21216 case value_t::object:
21218 m_data.m_value.object = create<object_t>(first.m_it.object_iterator,
21219 last.m_it.object_iterator);
21223 case value_t::array:
21225 m_data.m_value.array = create<array_t>(first.m_it.array_iterator,
21226 last.m_it.array_iterator);
21230 case value_t::binary:
21232 m_data.m_value = *first.m_object->m_data.m_value.binary;
21236 case value_t::null:
21237 case value_t::discarded:
21243 assert_invariant();
21250 template<
typename JsonRef,
21252 std::is_same<typename JsonRef::value_type, basic_json>>::value,
int> = 0 >
21258 : json_base_class_t(other)
21260 , start_position(other.start_position)
21261 , end_position(other.end_position)
21266 other.assert_invariant();
21270 case value_t::object:
21272 m_data.m_value = *other.m_data.m_value.object;
21276 case value_t::array:
21278 m_data.m_value = *other.m_data.m_value.array;
21282 case value_t::string:
21284 m_data.m_value = *other.m_data.m_value.string;
21288 case value_t::boolean:
21290 m_data.m_value = other.m_data.m_value.boolean;
21294 case value_t::number_integer:
21296 m_data.m_value = other.m_data.m_value.number_integer;
21300 case value_t::number_unsigned:
21302 m_data.m_value = other.m_data.m_value.number_unsigned;
21306 case value_t::number_float:
21308 m_data.m_value = other.m_data.m_value.number_float;
21312 case value_t::binary:
21314 m_data.m_value = *other.m_data.m_value.binary;
21318 case value_t::null:
21319 case value_t::discarded:
21325 assert_invariant();
21331 : json_base_class_t(std::forward<json_base_class_t>(other)),
21332 m_data(std::move(other.m_data))
21333#if JSON_DIAGNOSTIC_POSITIONS
21334 , start_position(other.start_position)
21335 , end_position(other.end_position)
21339 other.assert_invariant(
false);
21342 other.m_data.m_type = value_t::null;
21343 other.m_data.m_value = {};
21345#if JSON_DIAGNOSTIC_POSITIONS
21346 other.start_position = std::string::npos;
21347 other.end_position = std::string::npos;
21351 assert_invariant();
21357 std::is_nothrow_move_constructible<value_t>::value&&
21358 std::is_nothrow_move_assignable<value_t>::value&&
21359 std::is_nothrow_move_constructible<json_value>::value&&
21360 std::is_nothrow_move_assignable<json_value>::value&&
21361 std::is_nothrow_move_assignable<json_base_class_t>::value
21365 other.assert_invariant();
21371#if JSON_DIAGNOSTIC_POSITIONS
21372 swap(start_position, other.start_position);
21373 swap(end_position, other.end_position);
21376 json_base_class_t::operator=(std::move(other));
21379 assert_invariant();
21387 assert_invariant(
false);
21404 const char indent_char =
' ',
21405 const bool ensure_ascii =
false,
21413 s.dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(indent));
21417 s.dump(*
this,
false, ensure_ascii, 0);
21448 return m_data.m_type == value_t::null;
21455 return m_data.m_type == value_t::boolean;
21469 return m_data.m_type == value_t::number_integer ||
m_data.m_type == value_t::number_unsigned;
21476 return m_data.m_type == value_t::number_unsigned;
21483 return m_data.m_type == value_t::number_float;
21490 return m_data.m_type == value_t::object;
21497 return m_data.m_type == value_t::array;
21504 return m_data.m_type == value_t::string;
21511 return m_data.m_type == value_t::binary;
21518 return m_data.m_type == value_t::discarded;
21536 boolean_t get_impl(boolean_t* )
const
21540 return m_data.m_value.boolean;
21547 object_t* get_impl_ptr(object_t* )
noexcept
21549 return is_object() ? m_data.m_value.object :
nullptr;
21553 constexpr const object_t* get_impl_ptr(
const object_t* )
const noexcept
21555 return is_object() ? m_data.m_value.object :
nullptr;
21559 array_t* get_impl_ptr(array_t* )
noexcept
21561 return is_array() ? m_data.m_value.array :
nullptr;
21565 constexpr const array_t* get_impl_ptr(
const array_t* )
const noexcept
21567 return is_array() ? m_data.m_value.array :
nullptr;
21573 return is_string() ? m_data.m_value.string :
nullptr;
21579 return is_string() ? m_data.m_value.string :
nullptr;
21583 boolean_t* get_impl_ptr(boolean_t* )
noexcept
21585 return is_boolean() ? &m_data.m_value.boolean :
nullptr;
21589 constexpr const boolean_t* get_impl_ptr(
const boolean_t* )
const noexcept
21591 return is_boolean() ? &m_data.m_value.boolean :
nullptr;
21597 return m_data.m_type == value_t::number_integer ? &m_data.m_value.number_integer :
nullptr;
21603 return m_data.m_type == value_t::number_integer ? &m_data.m_value.number_integer :
nullptr;
21609 return is_number_unsigned() ? &m_data.m_value.number_unsigned :
nullptr;
21615 return is_number_unsigned() ? &m_data.m_value.number_unsigned :
nullptr;
21621 return is_number_float() ? &m_data.m_value.number_float :
nullptr;
21627 return is_number_float() ? &m_data.m_value.number_float :
nullptr;
21633 return is_binary() ? m_data.m_value.binary :
nullptr;
21639 return is_binary() ? m_data.m_value.binary :
nullptr;
21653 template<
typename ReferenceType,
typename ThisType>
21654 static ReferenceType get_ref_impl(ThisType& obj)
21657 auto* ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
21664 JSON_THROW(type_error::create(303,
detail::concat(
"incompatible ReferenceType for get_ref, actual type is ", obj.type_name()), &obj));
21674 template<
typename PointerType,
typename std::enable_if<
21675 std::is_pointer<PointerType>::value,
int>::type = 0>
21676 auto get_ptr() noexcept -> decltype(
std::declval<basic_json_t&>().get_impl_ptr(
std::declval<PointerType>()))
21679 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
21684 template <
typename PointerType,
typename std::enable_if <
21685 std::is_pointer<PointerType>::value&&
21686 std::is_const<typename std::remove_pointer<PointerType>::type>::value,
int >::type = 0 >
21687 constexpr auto get_ptr() const noexcept -> decltype(
std::declval<const basic_json_t&>().get_impl_ptr(
std::declval<PointerType>()))
21690 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
21732 template <
typename ValueType,
21738 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))
21740 auto ret = ValueType();
21741 JSONSerializer<ValueType>::from_json(*
this, ret);
21775 template <
typename ValueType,
21777 detail::has_non_default_from_json<basic_json_t, ValueType>::value,
21779 ValueType get_impl(detail::priority_tag<1> )
const noexcept(
noexcept(
21780 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>())))
21782 return JSONSerializer<ValueType>::from_json(*
this);
21800 template <
typename BasicJsonType,
21802 detail::is_basic_json<BasicJsonType>::value,
21804 BasicJsonType get_impl(detail::priority_tag<2> )
const
21823 template<
typename BasicJsonType,
21825 std::is_same<BasicJsonType, basic_json_t>::value,
21827 basic_json get_impl(detail::priority_tag<3> )
const
21836 template<
typename PointerType,
21838 std::is_pointer<PointerType>::value,
21840 constexpr auto get_impl(detail::priority_tag<4> )
const noexcept
21841 ->
decltype(std::declval<const basic_json_t&>().template get_ptr<PointerType>())
21844 return get_ptr<PointerType>();
21871 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
21872#if defined(JSON_HAS_CPP_14)
21876 noexcept(
std::declval<const basic_json_t&>().template get_impl<ValueType>(
detail::priority_tag<4> {})))
21882 static_assert(!std::is_reference<ValueTypeCV>::value,
21883 "get() cannot be used with reference types, you might want to use get_ref()");
21884 return get_impl<ValueType>(detail::priority_tag<4> {});
21914 template<
typename PointerType,
typename std::enable_if<
21915 std::is_pointer<PointerType>::value,
int>::type = 0>
21916 auto get() noexcept -> decltype(
std::declval<basic_json_t&>().template
get_ptr<PointerType>())
21924 template <
typename ValueType,
21929 ValueType &
get_to(ValueType& v)
const noexcept(
noexcept(
21930 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v)))
21932 JSONSerializer<ValueType>::from_json(*
this, v);
21938 template<
typename ValueType,
21949 typename T, std::size_t N,
21950 typename Array = T (&)[N],
21954 noexcept(
noexcept(JSONSerializer<Array>::from_json(
21955 std::declval<const basic_json_t&>(), v)))
21957 JSONSerializer<Array>::from_json(*
this, v);
21963 template<
typename ReferenceType,
typename std::enable_if<
21964 std::is_reference<ReferenceType>::value,
int>::type = 0>
21968 return get_ref_impl<ReferenceType>(*
this);
21973 template <
typename ReferenceType,
typename std::enable_if <
21974 std::is_reference<ReferenceType>::value&&
21975 std::is_const<typename std::remove_reference<ReferenceType>::type>::value,
int >::type = 0 >
21979 return get_ref_impl<ReferenceType>(*
this);
22011 template <
typename ValueType,
typename std::enable_if <
22019#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
22022#if defined(JSON_HAS_CPP_17) && JSON_HAS_STATIC_RTTI
22026 >::value,
int >::type = 0 >
22076 return set_parent(
m_data.m_value.array->at(idx));
22099 return m_data.m_value.array->at(idx);
22123 auto it =
m_data.m_value.object->find(
key);
22124 if (it ==
m_data.m_value.object->end())
22128 return set_parent(it->second);
22143 auto it =
m_data.m_value.object->find(std::forward<KeyType>(
key));
22144 if (it ==
m_data.m_value.object->end())
22148 return set_parent(it->second);
22161 auto it =
m_data.m_value.object->find(
key);
22162 if (it ==
m_data.m_value.object->end())
22181 auto it =
m_data.m_value.object->find(std::forward<KeyType>(
key));
22182 if (it ==
m_data.m_value.object->end())
22196 m_data.m_type = value_t::array;
22197 m_data.m_value.array = create<array_t>();
22198 assert_invariant();
22205 if (idx >=
m_data.m_value.array->size())
22207#if JSON_DIAGNOSTICS
22209 const auto old_size =
m_data.m_value.array->size();
22210 const auto old_capacity =
m_data.m_value.array->capacity();
22212 m_data.m_value.array->resize(idx + 1);
22214#if JSON_DIAGNOSTICS
22223 set_parents(
begin() +
static_cast<typename iterator::difference_type
>(old_size),
static_cast<typename iterator::difference_type
>(idx + 1 - old_size));
22226 assert_invariant();
22229 return m_data.m_value.array->operator[](idx);
22242 return m_data.m_value.array->operator[](idx);
22255 m_data.m_type = value_t::object;
22256 m_data.m_value.object = create<object_t>();
22257 assert_invariant();
22263 auto result =
m_data.m_value.object->emplace(std::move(
key),
nullptr);
22264 return set_parent(result.first->second);
22277 auto it =
m_data.m_value.object->find(
key);
22287 template<
typename T>
22293 template<
typename T>
22308 m_data.m_type = value_t::object;
22309 m_data.m_value.object = create<object_t>();
22310 assert_invariant();
22316 auto result =
m_data.m_value.object->emplace(std::forward<KeyType>(
key),
nullptr);
22317 return set_parent(result.first->second);
22332 auto it =
m_data.m_value.object->find(std::forward<KeyType>(
key));
22341 template<
typename KeyType>
22343 object_comparator_t,
const typename object_t::key_type&, KeyType >;
22345 template<
typename ValueType>
22346 using value_return_type = std::conditional <
22348 string_t,
typename std::decay<ValueType>::type >;
22356 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22357 ValueType
value(
const typename object_t::key_type&
key,
const ValueType& default_value)
const
22369 return default_value;
22377 template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
22381 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22382 ReturnType
value(
const typename object_t::key_type&
key, ValueType && default_value)
const
22394 return std::forward<ValueType>(default_value);
22405 && is_comparable_with_object_key<KeyType>::value
22407 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22408 ValueType
value(KeyType &&
key,
const ValueType& default_value)
const
22414 const auto it =
find(std::forward<KeyType>(
key));
22420 return default_value;
22428 template < class ValueType, class KeyType, class ReturnType = typename value_return_type<ValueType>::type,
22432 && is_comparable_with_object_key<KeyType>::value
22434 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22435 ReturnType
value(KeyType &&
key, ValueType && default_value)
const
22441 const auto it =
find(std::forward<KeyType>(
key));
22447 return std::forward<ValueType>(default_value);
22457 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22471 return default_value;
22480 template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
22483 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22497 return std::forward<ValueType>(default_value);
22507 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22509 ValueType
value(const ::nlohmann::
json_pointer<BasicJsonType>& ptr, const ValueType& default_value)
const
22511 return value(ptr.convert(), default_value);
22514 template < class ValueType, class BasicJsonType, class ReturnType = typename value_return_type<ValueType>::type,
22518 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22522 return value(ptr.convert(), std::forward<ValueType>(default_value));
22560 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
22561 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
22570 IteratorType result =
end();
22574 case value_t::boolean:
22575 case value_t::number_float:
22576 case value_t::number_integer:
22577 case value_t::number_unsigned:
22578 case value_t::string:
22579 case value_t::binary:
22588 AllocatorType<string_t> alloc;
22589 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_data.m_value.string);
22590 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_data.m_value.string, 1);
22591 m_data.m_value.string =
nullptr;
22595 AllocatorType<binary_t> alloc;
22596 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_data.m_value.binary);
22597 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_data.m_value.binary, 1);
22598 m_data.m_value.binary =
nullptr;
22601 m_data.m_type = value_t::null;
22602 assert_invariant();
22606 case value_t::object:
22608 result.m_it.object_iterator =
m_data.m_value.object->erase(pos.m_it.object_iterator);
22612 case value_t::array:
22614 result.m_it.array_iterator =
m_data.m_value.array->erase(pos.m_it.array_iterator);
22618 case value_t::null:
22619 case value_t::discarded:
22630 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
22631 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
22632 IteratorType
erase(IteratorType first, IteratorType last)
22640 IteratorType result =
end();
22644 case value_t::boolean:
22645 case value_t::number_float:
22646 case value_t::number_integer:
22647 case value_t::number_unsigned:
22648 case value_t::string:
22649 case value_t::binary:
22652 || !last.m_it.primitive_iterator.is_end()))
22659 AllocatorType<string_t> alloc;
22660 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_data.m_value.string);
22661 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_data.m_value.string, 1);
22662 m_data.m_value.string =
nullptr;
22666 AllocatorType<binary_t> alloc;
22667 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_data.m_value.binary);
22668 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_data.m_value.binary, 1);
22669 m_data.m_value.binary =
nullptr;
22672 m_data.m_type = value_t::null;
22673 assert_invariant();
22677 case value_t::object:
22679 result.m_it.object_iterator =
m_data.m_value.object->erase(first.m_it.object_iterator,
22680 last.m_it.object_iterator);
22684 case value_t::array:
22686 result.m_it.array_iterator =
m_data.m_value.array->erase(first.m_it.array_iterator,
22687 last.m_it.array_iterator);
22691 case value_t::null:
22692 case value_t::discarded:
22703 size_type erase_internal(KeyType &&
key)
22711 return m_data.m_value.object->erase(std::forward<KeyType>(
key));
22715 !detail::has_erase_with_key_type<basic_json_t, KeyType>::value,
int > = 0 >
22716 size_type erase_internal(KeyType &&
key)
22724 const auto it = m_data.m_value.object->find(std::forward<KeyType>(
key));
22725 if (it != m_data.m_value.object->end())
22727 m_data.m_value.object->erase(it);
22741 return erase_internal(
key);
22750 return erase_internal(std::forward<KeyType>(
key));
22786 auto result =
end();
22790 result.m_it.object_iterator =
m_data.m_value.object->find(
key);
22800 auto result =
cend();
22804 result.m_it.object_iterator =
m_data.m_value.object->find(
key);
22816 auto result =
end();
22820 result.m_it.object_iterator =
m_data.m_value.object->find(std::forward<KeyType>(
key));
22832 auto result =
cend();
22836 result.m_it.object_iterator =
m_data.m_value.object->find(std::forward<KeyType>(
key));
22880 return ptr.contains(
this);
22883 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
22887 return ptr.contains(
this);
22904 result.set_begin();
22920 result.set_begin();
23000 return ref.items();
23011 return ref.items();
23018 return iteration_proxy<iterator>(*
this);
23023 iteration_proxy<const_iterator>
items() const noexcept
23025 return iteration_proxy<const_iterator>(*
this);
23043 case value_t::null:
23049 case value_t::array:
23052 return m_data.m_value.array->empty();
23055 case value_t::object:
23058 return m_data.m_value.object->empty();
23061 case value_t::string:
23062 case value_t::boolean:
23063 case value_t::number_integer:
23064 case value_t::number_unsigned:
23065 case value_t::number_float:
23066 case value_t::binary:
23067 case value_t::discarded:
23082 case value_t::null:
23088 case value_t::array:
23091 return m_data.m_value.array->size();
23094 case value_t::object:
23097 return m_data.m_value.object->size();
23100 case value_t::string:
23101 case value_t::boolean:
23102 case value_t::number_integer:
23103 case value_t::number_unsigned:
23104 case value_t::number_float:
23105 case value_t::binary:
23106 case value_t::discarded:
23121 case value_t::array:
23124 return m_data.m_value.array->max_size();
23127 case value_t::object:
23130 return m_data.m_value.object->max_size();
23133 case value_t::null:
23134 case value_t::string:
23135 case value_t::boolean:
23136 case value_t::number_integer:
23137 case value_t::number_unsigned:
23138 case value_t::number_float:
23139 case value_t::binary:
23140 case value_t::discarded:
23164 case value_t::number_integer:
23166 m_data.m_value.number_integer = 0;
23170 case value_t::number_unsigned:
23172 m_data.m_value.number_unsigned = 0;
23176 case value_t::number_float:
23178 m_data.m_value.number_float = 0.0;
23182 case value_t::boolean:
23184 m_data.m_value.boolean =
false;
23188 case value_t::string:
23190 m_data.m_value.string->clear();
23194 case value_t::binary:
23196 m_data.m_value.binary->clear();
23200 case value_t::array:
23202 m_data.m_value.array->clear();
23206 case value_t::object:
23208 m_data.m_value.object->clear();
23212 case value_t::null:
23213 case value_t::discarded:
23232 m_data.m_type = value_t::array;
23233 m_data.m_value = value_t::array;
23234 assert_invariant();
23238 const auto old_capacity =
m_data.m_value.array->capacity();
23239 m_data.m_value.array->push_back(std::move(val));
23240 set_parent(
m_data.m_value.array->back(), old_capacity);
23265 m_data.m_type = value_t::array;
23266 m_data.m_value = value_t::array;
23267 assert_invariant();
23271 const auto old_capacity =
m_data.m_value.array->capacity();
23272 m_data.m_value.array->push_back(val);
23273 set_parent(
m_data.m_value.array->back(), old_capacity);
23297 m_data.m_type = value_t::object;
23298 m_data.m_value = value_t::object;
23299 assert_invariant();
23303 auto res =
m_data.m_value.object->insert(val);
23304 set_parent(res.first->second);
23319 if (
is_object() && init.size() == 2 && (*init.begin())->is_string())
23322 push_back(
typename object_t::value_type(
23323 std::move(
key.get_ref<
string_t&>()), (init.begin() + 1)->moved_or_copied()));
23341 template<
class... Args>
23353 m_data.m_type = value_t::array;
23354 m_data.m_value = value_t::array;
23355 assert_invariant();
23359 const auto old_capacity =
m_data.m_value.array->capacity();
23360 m_data.m_value.array->emplace_back(std::forward<Args>(args)...);
23361 return set_parent(
m_data.m_value.array->back(), old_capacity);
23366 template<
class... Args>
23378 m_data.m_type = value_t::object;
23379 m_data.m_value = value_t::object;
23380 assert_invariant();
23384 auto res =
m_data.m_value.object->emplace(std::forward<Args>(args)...);
23385 set_parent(res.first->second);
23389 it.m_it.object_iterator = res.first;
23392 return {it, res.second};
23398 template<
typename... Args>
23404 auto insert_pos = std::distance(
m_data.m_value.array->begin(), pos.m_it.array_iterator);
23405 m_data.m_value.array->insert(pos.m_it.array_iterator, std::forward<Args>(args)...);
23406 result.m_it.array_iterator =
m_data.m_value.array->begin() + insert_pos;
23440 return insert(pos, val);
23491 return insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator);
23536 m_data.m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator);
23554 m_data.m_type = value_t::object;
23555 m_data.m_value.object = create<object_t>();
23556 assert_invariant();
23576 for (
auto it = first; it != last; ++it)
23578 if (merge_objects && it.value().is_object())
23580 auto it2 =
m_data.m_value.object->find(it.key());
23581 if (it2 !=
m_data.m_value.object->end())
23583 it2->second.update(it.value(),
true);
23587 m_data.m_value.object->operator[](it.key()) = it.value();
23588#if JSON_DIAGNOSTICS
23589 m_data.m_value.object->operator[](it.key()).m_parent =
this;
23597 std::is_nothrow_move_constructible<value_t>::value&&
23598 std::is_nothrow_move_assignable<value_t>::value&&
23599 std::is_nothrow_move_constructible<json_value>::value&&
23600 std::is_nothrow_move_assignable<json_value>::value
23607 other.set_parents();
23608 assert_invariant();
23614 std::is_nothrow_move_constructible<value_t>::value&&
23615 std::is_nothrow_move_assignable<value_t>::value&&
23616 std::is_nothrow_move_constructible<json_value>::value&&
23617 std::is_nothrow_move_assignable<json_value>::value
23689 void swap(
typename binary_t::container_type& other)
23714#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result) \
23715 const auto lhs_type = lhs.type(); \
23716 const auto rhs_type = rhs.type(); \
23718 if (lhs_type == rhs_type) \
23720 switch (lhs_type) \
23722 case value_t::array: \
23723 return (*lhs.m_data.m_value.array) op (*rhs.m_data.m_value.array); \
23725 case value_t::object: \
23726 return (*lhs.m_data.m_value.object) op (*rhs.m_data.m_value.object); \
23728 case value_t::null: \
23729 return (null_result); \
23731 case value_t::string: \
23732 return (*lhs.m_data.m_value.string) op (*rhs.m_data.m_value.string); \
23734 case value_t::boolean: \
23735 return (lhs.m_data.m_value.boolean) op (rhs.m_data.m_value.boolean); \
23737 case value_t::number_integer: \
23738 return (lhs.m_data.m_value.number_integer) op (rhs.m_data.m_value.number_integer); \
23740 case value_t::number_unsigned: \
23741 return (lhs.m_data.m_value.number_unsigned) op (rhs.m_data.m_value.number_unsigned); \
23743 case value_t::number_float: \
23744 return (lhs.m_data.m_value.number_float) op (rhs.m_data.m_value.number_float); \
23746 case value_t::binary: \
23747 return (*lhs.m_data.m_value.binary) op (*rhs.m_data.m_value.binary); \
23749 case value_t::discarded: \
23751 return (unordered_result); \
23754 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) \
23756 return static_cast<number_float_t>(lhs.m_data.m_value.number_integer) op rhs.m_data.m_value.number_float; \
23758 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) \
23760 return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_integer); \
23762 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) \
23764 return static_cast<number_float_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_float; \
23766 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) \
23768 return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_unsigned); \
23770 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) \
23772 return static_cast<number_integer_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_integer; \
23774 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) \
23776 return lhs.m_data.m_value.number_integer op static_cast<number_integer_t>(rhs.m_data.m_value.number_unsigned); \
23778 else if(compares_unordered(lhs, rhs))\
23780 return (unordered_result);\
23783 return (default_result);
23794 || (
rhs.is_number_float() && std::isnan(
rhs.m_data.m_value.number_float) && lhs.
is_number()))
23798#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
23807 bool compares_unordered(const_reference rhs,
bool inverse =
false) const noexcept
23809 return compares_unordered(*
this, rhs, inverse);
23813#if JSON_HAS_THREE_WAY_COMPARISON
23816 bool operator==(const_reference rhs)
const noexcept
23819#pragma GCC diagnostic push
23820#pragma GCC diagnostic ignored "-Wfloat-equal"
23822 const_reference lhs = *
this;
23825#pragma GCC diagnostic pop
23831 template<
typename ScalarType>
23832 requires std::is_scalar_v<ScalarType>
23833 bool operator==(ScalarType rhs)
const noexcept
23835 return *
this == basic_json(rhs);
23840 bool operator!=(const_reference rhs)
const noexcept
23842 if (compares_unordered(rhs,
true))
23851 std::partial_ordering operator<=>(const_reference rhs)
const noexcept
23853 const_reference lhs = *
this;
23857 std::partial_ordering::equivalent,
23858 std::partial_ordering::unordered,
23859 lhs_type <=> rhs_type)
23864 template<
typename ScalarType>
23865 requires std::is_scalar_v<ScalarType>
23866 std::partial_ordering operator<=>(ScalarType rhs)
const noexcept
23868 return *this <=> basic_json(rhs);
23871#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
23878 bool operator<=(const_reference rhs)
const noexcept
23880 if (compares_unordered(rhs,
true))
23884 return !(rhs < *
this);
23889 template<
typename ScalarType>
23890 requires std::is_scalar_v<ScalarType>
23891 bool operator<=(ScalarType rhs)
const noexcept
23893 return *
this <= basic_json(rhs);
23899 bool operator>=(const_reference rhs)
const noexcept
23901 if (compares_unordered(rhs,
true))
23905 return !(*
this < rhs);
23910 template<
typename ScalarType>
23911 requires std::is_scalar_v<ScalarType>
23912 bool operator>=(ScalarType rhs)
const noexcept
23914 return *
this >= basic_json(rhs);
23920 friend bool operator==(const_reference lhs, const_reference rhs)
noexcept
23923#pragma GCC diagnostic push
23924#pragma GCC diagnostic ignored "-Wfloat-equal"
23928#pragma GCC diagnostic pop
23934 template<
typename ScalarType,
typename std::enable_if<
23935 std::is_scalar<ScalarType>::value,
int>::type = 0>
23936 friend bool operator==(const_reference lhs, ScalarType rhs)
noexcept
23938 return lhs == basic_json(rhs);
23943 template<
typename ScalarType,
typename std::enable_if<
23944 std::is_scalar<ScalarType>::value,
int>::type = 0>
23945 friend bool operator==(ScalarType lhs, const_reference rhs)
noexcept
23947 return basic_json(lhs) == rhs;
23952 friend bool operator!=(const_reference lhs, const_reference rhs)
noexcept
23954 if (compares_unordered(lhs, rhs,
true))
23958 return !(lhs == rhs);
23963 template<
typename ScalarType,
typename std::enable_if<
23964 std::is_scalar<ScalarType>::value,
int>::type = 0>
23965 friend bool operator!=(const_reference lhs, ScalarType rhs)
noexcept
23967 return lhs != basic_json(rhs);
23972 template<
typename ScalarType,
typename std::enable_if<
23973 std::is_scalar<ScalarType>::value,
int>::type = 0>
23974 friend bool operator!=(ScalarType lhs, const_reference rhs)
noexcept
23976 return basic_json(lhs) != rhs;
23981 friend bool operator<(const_reference lhs, const_reference rhs)
noexcept
23991 template<
typename ScalarType,
typename std::enable_if<
23992 std::is_scalar<ScalarType>::value,
int>::type = 0>
23993 friend bool operator<(const_reference lhs, ScalarType rhs)
noexcept
23995 return lhs < basic_json(rhs);
24000 template<
typename ScalarType,
typename std::enable_if<
24001 std::is_scalar<ScalarType>::value,
int>::type = 0>
24002 friend bool operator<(ScalarType lhs, const_reference rhs)
noexcept
24004 return basic_json(lhs) < rhs;
24009 friend bool operator<=(const_reference lhs, const_reference rhs)
noexcept
24011 if (compares_unordered(lhs, rhs,
true))
24015 return !(rhs < lhs);
24020 template<
typename ScalarType,
typename std::enable_if<
24021 std::is_scalar<ScalarType>::value,
int>::type = 0>
24022 friend bool operator<=(const_reference lhs, ScalarType rhs)
noexcept
24024 return lhs <= basic_json(rhs);
24029 template<
typename ScalarType,
typename std::enable_if<
24030 std::is_scalar<ScalarType>::value,
int>::type = 0>
24031 friend bool operator<=(ScalarType lhs, const_reference rhs)
noexcept
24033 return basic_json(lhs) <= rhs;
24038 friend bool operator>(const_reference lhs, const_reference rhs)
noexcept
24041 if (compares_unordered(lhs, rhs))
24045 return !(lhs <= rhs);
24050 template<
typename ScalarType,
typename std::enable_if<
24051 std::is_scalar<ScalarType>::value,
int>::type = 0>
24052 friend bool operator>(const_reference lhs, ScalarType rhs)
noexcept
24054 return lhs > basic_json(rhs);
24059 template<
typename ScalarType,
typename std::enable_if<
24060 std::is_scalar<ScalarType>::value,
int>::type = 0>
24061 friend bool operator>(ScalarType lhs, const_reference rhs)
noexcept
24063 return basic_json(lhs) > rhs;
24068 friend bool operator>=(const_reference lhs, const_reference rhs)
noexcept
24070 if (compares_unordered(lhs, rhs,
true))
24074 return !(lhs < rhs);
24079 template<
typename ScalarType,
typename std::enable_if<
24080 std::is_scalar<ScalarType>::value,
int>::type = 0>
24081 friend bool operator>=(const_reference lhs, ScalarType rhs)
noexcept
24083 return lhs >= basic_json(rhs);
24088 template<
typename ScalarType,
typename std::enable_if<
24089 std::is_scalar<ScalarType>::value,
int>::type = 0>
24090 friend bool operator>=(ScalarType lhs, const_reference rhs)
noexcept
24092 return basic_json(lhs) >= rhs;
24096#undef JSON_IMPLEMENT_OPERATOR
24109 friend std::ostream& operator<<(std::ostream& o,
const basic_json& j)
24112 const bool pretty_print = o.width() > 0;
24113 const auto indentation = pretty_print ? o.width() : 0;
24119 serializer s(detail::output_adapter<char>(o), o.fill());
24120 s.dump(j, pretty_print,
false,
static_cast<unsigned int>(indentation));
24131 friend std::ostream& operator>>(
const basic_json& j, std::ostream& o)
24147 template<
typename InputType>
24149 static basic_json parse(InputType&& i,
24150 parser_callback_t cb =
nullptr,
24151 const bool allow_exceptions =
true,
24152 const bool ignore_comments =
false,
24153 const bool ignore_trailing_commas =
false)
24156 parser(
detail::input_adapter(std::forward<InputType>(i)), std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas).parse(
true, result);
24162 template<
typename IteratorType>
24164 static basic_json parse(IteratorType first,
24166 parser_callback_t cb =
nullptr,
24167 const bool allow_exceptions =
true,
24168 const bool ignore_comments =
false,
24169 const bool ignore_trailing_commas =
false)
24172 parser(
detail::input_adapter(std::move(first), std::move(last)), std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas).parse(
true, result);
24178 static basic_json parse(detail::span_input_adapter&& i,
24179 parser_callback_t cb =
nullptr,
24180 const bool allow_exceptions =
true,
24181 const bool ignore_comments =
false,
24182 const bool ignore_trailing_commas =
false)
24185 parser(i.get(), std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas).parse(
true, result);
24191 template<
typename InputType>
24192 static bool accept(InputType&& i,
24193 const bool ignore_comments =
false,
24194 const bool ignore_trailing_commas =
false)
24196 return parser(
detail::input_adapter(std::forward<InputType>(i)),
nullptr,
false, ignore_comments, ignore_trailing_commas).accept(
true);
24201 template<
typename IteratorType>
24202 static bool accept(IteratorType first, IteratorType last,
24203 const bool ignore_comments =
false,
24204 const bool ignore_trailing_commas =
false)
24206 return parser(
detail::input_adapter(std::move(first), std::move(last)),
nullptr,
false, ignore_comments, ignore_trailing_commas).accept(
true);
24211 static bool accept(detail::span_input_adapter&& i,
24212 const bool ignore_comments =
false,
24213 const bool ignore_trailing_commas =
false)
24215 return parser(i.get(),
nullptr,
false, ignore_comments, ignore_trailing_commas).accept(
true);
24220 template <
typename InputType,
typename SAX>
24224 const
bool strict = true,
24225 const
bool ignore_comments = false,
24226 const
bool ignore_trailing_commas = false)
24229 return format == input_format_t::json
24230 ?
parser(std::move(ia),
nullptr,
true, ignore_comments, ignore_trailing_commas).sax_parse(sax, strict)
24236 template<
class IteratorType,
class SAX>
24238 static
bool sax_parse(IteratorType first, IteratorType last, SAX* sax,
24240 const
bool strict = true,
24241 const
bool ignore_comments = false,
24242 const
bool ignore_trailing_commas = false)
24245 return format == input_format_t::json
24246 ?
parser(std::move(ia),
nullptr,
true, ignore_comments, ignore_trailing_commas).sax_parse(sax, strict)
24255 template <
typename SAX>
24260 const
bool strict = true,
24261 const
bool ignore_comments = false,
24262 const
bool ignore_trailing_commas = false)
24265 return format == input_format_t::json
24267 ?
parser(std::move(ia),
nullptr,
true, ignore_comments, ignore_trailing_commas).sax_parse(sax, strict)
24305 case value_t::null:
24307 case value_t::object:
24309 case value_t::array:
24311 case value_t::string:
24313 case value_t::boolean:
24315 case value_t::binary:
24317 case value_t::discarded:
24318 return "discarded";
24319 case value_t::number_integer:
24320 case value_t::number_unsigned:
24321 case value_t::number_float:
24336 value_t m_type = value_t::null;
24349 m_value.array = create<array_t>(cnt, val);
24366#if JSON_DIAGNOSTICS
24371#if JSON_DIAGNOSTIC_POSITIONS
24373 std::size_t start_position = std::string::npos;
24375 std::size_t end_position = std::string::npos;
24377 constexpr std::size_t start_pos() const noexcept
24379 return start_position;
24382 constexpr std::size_t end_pos() const noexcept
24384 return end_position;
24400 std::vector<std::uint8_t> result;
24409 binary_writer<std::uint8_t>(o).write_cbor(j);
24416 binary_writer<char>(o).write_cbor(j);
24423 std::vector<std::uint8_t> result;
24432 binary_writer<std::uint8_t>(o).write_msgpack(j);
24439 binary_writer<char>(o).write_msgpack(j);
24445 const bool use_size =
false,
24446 const bool use_type =
false)
24448 std::vector<std::uint8_t> result;
24449 to_ubjson(j, result, use_size, use_type);
24456 const bool use_size =
false,
const bool use_type =
false)
24458 binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type);
24464 const bool use_size =
false,
const bool use_type =
false)
24466 binary_writer<char>(o).write_ubjson(j, use_size, use_type);
24472 const bool use_size =
false,
24473 const bool use_type =
false,
24476 std::vector<std::uint8_t> result;
24477 to_bjdata(j, result, use_size, use_type, version);
24484 const bool use_size =
false,
const bool use_type =
false,
24487 binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type,
true,
true, version);
24493 const bool use_size =
false,
const bool use_type =
false,
24496 binary_writer<char>(o).write_ubjson(j, use_size, use_type,
true,
true, version);
24503 std::vector<std::uint8_t> result;
24512 binary_writer<std::uint8_t>(o).write_bson(j);
24519 binary_writer<char>(o).write_bson(j);
24524 template<
typename InputType>
24527 const bool strict =
true,
24528 const bool allow_exceptions =
true,
24534 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
24535 return res ? result :
basic_json(value_t::discarded);
24540 template<
typename IteratorType>
24543 const bool strict =
true,
24544 const bool allow_exceptions =
true,
24550 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
24551 return res ? result :
basic_json(value_t::discarded);
24554 template<
typename T>
24558 const
bool strict = true,
24559 const
bool allow_exceptions = true,
24562 return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
24568 const
bool strict = true,
24569 const
bool allow_exceptions = true,
24576 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
24577 return res ? result :
basic_json(value_t::discarded);
24582 template<
typename InputType>
24585 const bool strict =
true,
24586 const bool allow_exceptions =
true)
24591 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
24592 return res ? result :
basic_json(value_t::discarded);
24597 template<
typename IteratorType>
24600 const bool strict =
true,
24601 const bool allow_exceptions =
true)
24606 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
24607 return res ? result :
basic_json(value_t::discarded);
24610 template<
typename T>
24614 const
bool strict = true,
24615 const
bool allow_exceptions = true)
24617 return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
24623 const
bool strict = true,
24624 const
bool allow_exceptions = true)
24630 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
24631 return res ? result :
basic_json(value_t::discarded);
24636 template<
typename InputType>
24639 const bool strict =
true,
24640 const bool allow_exceptions =
true)
24645 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
24646 return res ? result :
basic_json(value_t::discarded);
24651 template<
typename IteratorType>
24654 const bool strict =
true,
24655 const bool allow_exceptions =
true)
24660 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
24661 return res ? result :
basic_json(value_t::discarded);
24664 template<
typename T>
24668 const
bool strict = true,
24669 const
bool allow_exceptions = true)
24671 return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
24677 const
bool strict = true,
24678 const
bool allow_exceptions = true)
24684 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
24685 return res ? result :
basic_json(value_t::discarded);
24690 template<
typename InputType>
24693 const bool strict =
true,
24694 const bool allow_exceptions =
true)
24699 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
24700 return res ? result :
basic_json(value_t::discarded);
24705 template<
typename IteratorType>
24708 const bool strict =
true,
24709 const bool allow_exceptions =
true)
24714 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
24715 return res ? result :
basic_json(value_t::discarded);
24720 template<
typename InputType>
24723 const bool strict =
true,
24724 const bool allow_exceptions =
true)
24729 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
24730 return res ? result :
basic_json(value_t::discarded);
24735 template<
typename IteratorType>
24738 const bool strict =
true,
24739 const bool allow_exceptions =
true)
24744 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
24745 return res ? result :
basic_json(value_t::discarded);
24748 template<
typename T>
24752 const
bool strict = true,
24753 const
bool allow_exceptions = true)
24755 return from_bson(ptr, ptr + len, strict, allow_exceptions);
24761 const
bool strict = true,
24762 const
bool allow_exceptions = true)
24768 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
24769 return res ? result :
basic_json(value_t::discarded);
24784 return ptr.get_unchecked(
this);
24787 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24791 return ptr.get_unchecked(
this);
24798 return ptr.get_unchecked(
this);
24801 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24805 return ptr.get_unchecked(
this);
24812 return ptr.get_checked(
this);
24815 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24819 return ptr.get_checked(
this);
24826 return ptr.get_checked(
this);
24829 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24833 return ptr.get_checked(
this);
24841 json_pointer::flatten(
"", *
this, result);
24849 return json_pointer::unflatten(*
this);
24867 enum class patch_operations {add, remove, replace, move, copy, test, invalid};
24869 const auto get_op = [](
const string_t& op)
24873 return patch_operations::add;
24875 if (op ==
"remove")
24877 return patch_operations::remove;
24879 if (op ==
"replace")
24881 return patch_operations::replace;
24885 return patch_operations::move;
24889 return patch_operations::copy;
24893 return patch_operations::test;
24896 return patch_operations::invalid;
24911 if (top_pointer != ptr)
24913 result.
at(top_pointer);
24917 const auto last_path = ptr.
back();
24922 switch (parent.
m_data.m_type)
24924 case value_t::null:
24925 case value_t::object:
24928 parent[last_path] = val;
24932 case value_t::array:
24934 if (last_path ==
"-")
24941 const auto idx = json_pointer::template array_index<basic_json_t>(last_path);
24955 case value_t::string:
24956 case value_t::boolean:
24957 case value_t::number_integer:
24958 case value_t::number_unsigned:
24959 case value_t::number_float:
24960 case value_t::binary:
24961 case value_t::discarded:
24968 const auto operation_remove = [
this, & result](
json_pointer & ptr)
24971 const auto last_path = ptr.
back();
24979 auto it = parent.
find(last_path);
24992 parent.
erase(json_pointer::template array_index<basic_json_t>(last_path));
25003 for (
const auto& val : json_patch)
25006 const auto get_value = [&val](
const string_t& op,
25011 auto it = val.m_data.m_value.object->find(member);
25014 const auto error_msg = (op ==
"op") ?
"operation" :
detail::concat(
"operation '", op,
'\'');
25041 const auto op = get_value(
"op",
"op",
true).template
get<string_t>();
25042 const auto path = get_value(op,
"path",
true).template
get<string_t>();
25045 switch (get_op(op))
25047 case patch_operations::add:
25049 operation_add(ptr, get_value(
"add",
"value",
false));
25053 case patch_operations::remove:
25055 operation_remove(ptr);
25059 case patch_operations::replace:
25062 result.
at(ptr) = get_value(
"replace",
"value",
false);
25066 case patch_operations::move:
25068 const auto from_path = get_value(
"move",
"from",
true).template
get<string_t>();
25078 operation_remove(from_ptr);
25079 operation_add(ptr, v);
25083 case patch_operations::copy:
25085 const auto from_path = get_value(
"copy",
"from",
true).template
get<string_t>();
25094 operation_add(ptr, v);
25098 case patch_operations::test:
25100 bool success =
false;
25105 success = (result.
at(ptr) == get_value(
"test",
"value",
false));
25121 case patch_operations::invalid:
25151 if (source == target)
25156 if (source.
type() != target.
type())
25161 {
"op",
"replace"}, {
"path", path}, {
"value", target}
25166 switch (source.
type())
25168 case value_t::array:
25172 while (i < source.
size() && i < target.
size())
25176 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
25185 while (i < source.
size())
25189 result.
insert(result.
begin() + end_index,
object(
25192 {
"path", detail::concat<string_t>(path,
'/', detail::to_string<string_t>(i))}
25198 while (i < target.
size())
25204 {
"value", target[i]}
25212 case value_t::object:
25215 for (
auto it = source.
cbegin(); it != source.
cend(); ++it)
25220 if (target.
find(it.key()) != target.
end())
25223 auto temp_diff =
diff(it.value(), target[it.key()], path_key);
25224 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
25231 {
"op",
"remove"}, {
"path", path_key}
25237 for (
auto it = target.
cbegin(); it != target.
cend(); ++it)
25239 if (source.
find(it.key()) == source.
end())
25245 {
"op",
"add"}, {
"path", path_key},
25246 {
"value", it.value()}
25254 case value_t::null:
25255 case value_t::string:
25256 case value_t::boolean:
25257 case value_t::number_integer:
25258 case value_t::number_unsigned:
25259 case value_t::number_float:
25260 case value_t::binary:
25261 case value_t::discarded:
25267 {
"op",
"replace"}, {
"path", path}, {
"value", target}
25294 for (
auto it = apply_patch.
begin(); it != apply_patch.
end(); ++it)
25296 if (it.value().is_null())
25302 operator[](it.key()).merge_patch(it.value());
25308 *
this = apply_patch;
25331#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
25332 inline nlohmann::json
operator ""_json(
const char* s, std::size_t n)
25334 inline nlohmann::json
operator "" _json(
const char* s, std::size_t n)
25337 return nlohmann::json::parse(s, s + n);
25343#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
25344 inline nlohmann::json::json_pointer
operator ""_json_pointer(
const char* s, std::size_t n)
25346 inline nlohmann::json::json_pointer
operator "" _json_pointer(
const char* s, std::size_t n)
25349 return nlohmann::json::json_pointer(std::string(s, n));
25368 std::size_t
operator()(
const nlohmann::NLOHMANN_BASIC_JSON_TPL& j)
const
25370 return nlohmann::detail::hash(j);
25376struct less< ::nlohmann::detail::value_t>
25383 ::nlohmann::detail::value_t rhs)
const noexcept
25385#if JSON_HAS_THREE_WAY_COMPARISON
25386 return std::is_lt(lhs <=> rhs);
25388 return ::nlohmann::detail::operator<(lhs, rhs);
25394#ifndef JSON_HAS_CPP_20
25399inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC_JSON_TPL& j2)
noexcept(
25400 is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value&&
25401 is_nothrow_move_assignable<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value)
25410#if JSON_USE_GLOBAL_UDLS
25411 #if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
25412 using nlohmann::literals::json_literals::operator
""_json;
25413 using nlohmann::literals::json_literals::operator
""_json_pointer;
25415 using nlohmann::literals::json_literals::operator
"" _json;
25416 using nlohmann::literals::json_literals::operator
"" _json_pointer;
25432#if defined(__clang__)
25433 #pragma clang diagnostic pop
25438#undef JSON_INTERNAL_CATCH
25440#undef JSON_PRIVATE_UNLESS_TESTED
25441#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
25442#undef NLOHMANN_BASIC_JSON_TPL
25443#undef JSON_EXPLICIT
25444#undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL
25445#undef JSON_INLINE_VARIABLE
25446#undef JSON_NO_UNIQUE_ADDRESS
25447#undef JSON_DISABLE_ENUM_SERIALIZATION
25448#undef JSON_USE_GLOBAL_UDLS
25450#ifndef JSON_TEST_KEEP_MACROS
25453 #undef JSON_HAS_CPP_11
25454 #undef JSON_HAS_CPP_14
25455 #undef JSON_HAS_CPP_17
25456 #undef JSON_HAS_CPP_20
25457 #undef JSON_HAS_CPP_23
25458 #undef JSON_HAS_CPP_26
25459 #undef JSON_HAS_FILESYSTEM
25460 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
25461 #undef JSON_HAS_THREE_WAY_COMPARISON
25462 #undef JSON_HAS_RANGES
25463 #undef JSON_HAS_STATIC_RTTI
25464 #undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
25478#undef JSON_HEDLEY_ALWAYS_INLINE
25479#undef JSON_HEDLEY_ARM_VERSION
25480#undef JSON_HEDLEY_ARM_VERSION_CHECK
25481#undef JSON_HEDLEY_ARRAY_PARAM
25482#undef JSON_HEDLEY_ASSUME
25483#undef JSON_HEDLEY_BEGIN_C_DECLS
25484#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
25485#undef JSON_HEDLEY_CLANG_HAS_BUILTIN
25486#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
25487#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
25488#undef JSON_HEDLEY_CLANG_HAS_EXTENSION
25489#undef JSON_HEDLEY_CLANG_HAS_FEATURE
25490#undef JSON_HEDLEY_CLANG_HAS_WARNING
25491#undef JSON_HEDLEY_COMPCERT_VERSION
25492#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
25493#undef JSON_HEDLEY_CONCAT
25494#undef JSON_HEDLEY_CONCAT3
25495#undef JSON_HEDLEY_CONCAT3_EX
25496#undef JSON_HEDLEY_CONCAT_EX
25497#undef JSON_HEDLEY_CONST
25498#undef JSON_HEDLEY_CONSTEXPR
25499#undef JSON_HEDLEY_CONST_CAST
25500#undef JSON_HEDLEY_CPP_CAST
25501#undef JSON_HEDLEY_CRAY_VERSION
25502#undef JSON_HEDLEY_CRAY_VERSION_CHECK
25503#undef JSON_HEDLEY_C_DECL
25504#undef JSON_HEDLEY_DEPRECATED
25505#undef JSON_HEDLEY_DEPRECATED_FOR
25506#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
25507#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
25508#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
25509#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
25510#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
25511#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
25512#undef JSON_HEDLEY_DIAGNOSTIC_POP
25513#undef JSON_HEDLEY_DIAGNOSTIC_PUSH
25514#undef JSON_HEDLEY_DMC_VERSION
25515#undef JSON_HEDLEY_DMC_VERSION_CHECK
25516#undef JSON_HEDLEY_EMPTY_BASES
25517#undef JSON_HEDLEY_EMSCRIPTEN_VERSION
25518#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
25519#undef JSON_HEDLEY_END_C_DECLS
25520#undef JSON_HEDLEY_FLAGS
25521#undef JSON_HEDLEY_FLAGS_CAST
25522#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
25523#undef JSON_HEDLEY_GCC_HAS_BUILTIN
25524#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
25525#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
25526#undef JSON_HEDLEY_GCC_HAS_EXTENSION
25527#undef JSON_HEDLEY_GCC_HAS_FEATURE
25528#undef JSON_HEDLEY_GCC_HAS_WARNING
25529#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
25530#undef JSON_HEDLEY_GCC_VERSION
25531#undef JSON_HEDLEY_GCC_VERSION_CHECK
25532#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
25533#undef JSON_HEDLEY_GNUC_HAS_BUILTIN
25534#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
25535#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
25536#undef JSON_HEDLEY_GNUC_HAS_EXTENSION
25537#undef JSON_HEDLEY_GNUC_HAS_FEATURE
25538#undef JSON_HEDLEY_GNUC_HAS_WARNING
25539#undef JSON_HEDLEY_GNUC_VERSION
25540#undef JSON_HEDLEY_GNUC_VERSION_CHECK
25541#undef JSON_HEDLEY_HAS_ATTRIBUTE
25542#undef JSON_HEDLEY_HAS_BUILTIN
25543#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
25544#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
25545#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
25546#undef JSON_HEDLEY_HAS_EXTENSION
25547#undef JSON_HEDLEY_HAS_FEATURE
25548#undef JSON_HEDLEY_HAS_WARNING
25549#undef JSON_HEDLEY_IAR_VERSION
25550#undef JSON_HEDLEY_IAR_VERSION_CHECK
25551#undef JSON_HEDLEY_IBM_VERSION
25552#undef JSON_HEDLEY_IBM_VERSION_CHECK
25553#undef JSON_HEDLEY_IMPORT
25554#undef JSON_HEDLEY_INLINE
25555#undef JSON_HEDLEY_INTEL_CL_VERSION
25556#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
25557#undef JSON_HEDLEY_INTEL_VERSION
25558#undef JSON_HEDLEY_INTEL_VERSION_CHECK
25559#undef JSON_HEDLEY_IS_CONSTANT
25560#undef JSON_HEDLEY_IS_CONSTEXPR_
25561#undef JSON_HEDLEY_LIKELY
25562#undef JSON_HEDLEY_MALLOC
25563#undef JSON_HEDLEY_MCST_LCC_VERSION
25564#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
25565#undef JSON_HEDLEY_MESSAGE
25566#undef JSON_HEDLEY_MSVC_VERSION
25567#undef JSON_HEDLEY_MSVC_VERSION_CHECK
25568#undef JSON_HEDLEY_NEVER_INLINE
25569#undef JSON_HEDLEY_NON_NULL
25570#undef JSON_HEDLEY_NO_ESCAPE
25571#undef JSON_HEDLEY_NO_RETURN
25572#undef JSON_HEDLEY_NO_THROW
25573#undef JSON_HEDLEY_NULL
25574#undef JSON_HEDLEY_PELLES_VERSION
25575#undef JSON_HEDLEY_PELLES_VERSION_CHECK
25576#undef JSON_HEDLEY_PGI_VERSION
25577#undef JSON_HEDLEY_PGI_VERSION_CHECK
25578#undef JSON_HEDLEY_PREDICT
25579#undef JSON_HEDLEY_PRINTF_FORMAT
25580#undef JSON_HEDLEY_PRIVATE
25581#undef JSON_HEDLEY_PUBLIC
25582#undef JSON_HEDLEY_PURE
25583#undef JSON_HEDLEY_REINTERPRET_CAST
25584#undef JSON_HEDLEY_REQUIRE
25585#undef JSON_HEDLEY_REQUIRE_CONSTEXPR
25586#undef JSON_HEDLEY_REQUIRE_MSG
25587#undef JSON_HEDLEY_RESTRICT
25588#undef JSON_HEDLEY_RETURNS_NON_NULL
25589#undef JSON_HEDLEY_SENTINEL
25590#undef JSON_HEDLEY_STATIC_ASSERT
25591#undef JSON_HEDLEY_STATIC_CAST
25592#undef JSON_HEDLEY_STRINGIFY
25593#undef JSON_HEDLEY_STRINGIFY_EX
25594#undef JSON_HEDLEY_SUNPRO_VERSION
25595#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
25596#undef JSON_HEDLEY_TINYC_VERSION
25597#undef JSON_HEDLEY_TINYC_VERSION_CHECK
25598#undef JSON_HEDLEY_TI_ARMCL_VERSION
25599#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
25600#undef JSON_HEDLEY_TI_CL2000_VERSION
25601#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
25602#undef JSON_HEDLEY_TI_CL430_VERSION
25603#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
25604#undef JSON_HEDLEY_TI_CL6X_VERSION
25605#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
25606#undef JSON_HEDLEY_TI_CL7X_VERSION
25607#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
25608#undef JSON_HEDLEY_TI_CLPRU_VERSION
25609#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
25610#undef JSON_HEDLEY_TI_VERSION
25611#undef JSON_HEDLEY_TI_VERSION_CHECK
25612#undef JSON_HEDLEY_UNAVAILABLE
25613#undef JSON_HEDLEY_UNLIKELY
25614#undef JSON_HEDLEY_UNPREDICTABLE
25615#undef JSON_HEDLEY_UNREACHABLE
25616#undef JSON_HEDLEY_UNREACHABLE_RETURN
25617#undef JSON_HEDLEY_VERSION
25618#undef JSON_HEDLEY_VERSION_DECODE_MAJOR
25619#undef JSON_HEDLEY_VERSION_DECODE_MINOR
25620#undef JSON_HEDLEY_VERSION_DECODE_REVISION
25621#undef JSON_HEDLEY_VERSION_ENCODE
25622#undef JSON_HEDLEY_WARNING
25623#undef JSON_HEDLEY_WARN_UNUSED_RESULT
25624#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
25625#undef JSON_HEDLEY_FALL_THROUGH
namespace for Niels Lohmann
constexpr bool is_string() const noexcept
size_type erase(const typename object_t::key_type &key)
remove element from a JSON object given a key
detail::cbor_tag_handler_t cbor_tag_handler_t
reference operator[](KeyType &&key)
access specified object element
size_type size() const noexcept
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
auto get() const noexcept(noexcept(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))) -> decltype(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))
const_iterator end() const noexcept
returns an iterator to one past the last element
reference back()
access the last element
basic_json(CompatibleType &&val) noexcept(noexcept(//NOLINT(bugprone-forwarding-reference-overload, bugprone-exception-escape) JSONSerializer< U >::to_json(std::declval< basic_json_t & >(), std::forward< CompatibleType >(val))))
create a JSON value from compatible types
detail::parse_error parse_error
reverse_iterator rbegin() noexcept
returns an iterator to the reverse-beginning
detail::input_format_t input_format_t
basic_json patch(const basic_json &json_patch) const
applies a JSON patch to a copy of the current object
JSON_HEDLEY_RETURNS_NON_NULL const char * type_name() const noexcept
const_reference front() const
access the first element
constexpr bool is_array() const noexcept
void swap(reference other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&//NOLINT(cppcoreguidelines-noexcept-swap, performance-noexcept-swap) std::is_nothrow_move_assignable< json_value >::value)
ReturnType value(const json_pointer &ptr, ValueType &&default_value) const
access specified object element via JSON Pointer with default value
size_type count(KeyType &&key) const
returns the number of occurrences of a key in a JSON object
iter_impl< const basic_json > const_iterator
constexpr bool is_number_integer() const noexcept
json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
data(size_type cnt, const basic_json &val)
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
reference operator[](const json_pointer &ptr)
access specified element via JSON Pointer
typename std::allocator_traits< allocator_type >::const_pointer const_pointer
detail::type_error type_error
constexpr bool is_structured() const noexcept
return whether type is structured
const_reference operator[](KeyType &&key) const
access specified object element
detail::error_handler_t error_handler_t
const value_type & const_reference
detail::invalid_iterator invalid_iterator
void swap(binary_t &other)
exchanges the values
size_type max_size() const noexcept
returns the maximum possible number of elements
void update(const_reference j, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
ReferenceType get_ref() const
get a reference value (implicit)
constexpr bool is_discarded() const noexcept
return whether value is discarded
JSON_PRIVATE_UNLESS_TESTED const_reference rhs
reference operator+=(initializer_list_t init)
add an object to an object
void push_back(basic_json &&val)
add an object to an array
const_reference operator[](const typename object_t::key_type &key) const
access specified object element
iteration_proxy< const_iterator > items() const noexcept
helper to access iterator member functions in range-based for
const_reference back() const
access the last element
IteratorType erase(IteratorType first, IteratorType last)
remove elements given an iterator range
reference operator+=(const basic_json &val)
add an object to an array
friend void swap(reference left, reference right) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&//NOLINT(cppcoreguidelines-noexcept-swap, performance-noexcept-swap) std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
inserts copies of element into array
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
static allocator_type get_allocator()
returns the allocator associated with the container
nlohmann::byte_container_with_subtype< std::vector< std::uint8_t > > binary_t
reference at(KeyType &&key)
access specified object element with bounds checking
constexpr bool is_number_unsigned() const noexcept
return whether value is an unsigned integer number
void update(const_iterator first, const_iterator last, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
static std::vector< std::uint8_t > to_bson(const basic_json &j)
create a BSON serialization of a given JSON value
detail::exception exception
const_reverse_iterator rbegin() const noexcept
returns an iterator to the reverse-beginning
void push_back(initializer_list_t init)
add an object to an object
detail::parser_callback_t< basic_json > parser_callback_t
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json object(initializer_list_t init={})
explicitly create an object from an initializer list
ValueType & get_to(ValueType &v) const
static void to_msgpack(const basic_json &j, detail::output_adapter< char > o)
create a MessagePack serialization of a given JSON value
iterator begin() noexcept
detail::parse_event_t parse_event_t
JSON_PRIVATE_UNLESS_TESTED const_reference bool inverse
ReturnType value(const typename object_t::key_type &key, ValueType &&default_value) const
access specified object element with default value
const_iterator cend() const noexcept
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
const_reference at(const json_pointer &ptr) const
access specified element via JSON Pointer
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init)
explicitly create a binary array
basic_json(std::nullptr_t=nullptr) noexcept
create a null object
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(InputType &&i, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
basic_json flatten() const
return flattened JSON value
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
size_type erase(KeyType &&key)
remove element from a JSON object given a key
JSON_PRIVATE_UNLESS_TESTED const_reference bool static SAX bool sax_parse(InputType &&i, SAX *sax, input_format_t format=input_format_t::json, const bool strict=true, const bool ignore_comments=false, const bool ignore_trailing_commas=false)
std::vector< basic_json, std::allocator< basic_json > > array_t
nlohmann::ordered_map< std::string, basic_json, default_object_comparator_t, std::allocator< std::pair< const std::string, basic_json > > > object_t
const binary_t & get_binary() const
get a binary value
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
inserts range of elements into array
void patch_inplace(const basic_json &json_patch)
applies a JSON patch in-place without copying the object
ReturnType value(KeyType &&key, ValueType &&default_value) const
access specified object element via JSON Pointer with default value
const_reference operator[](const json_pointer &ptr) const
access specified element via JSON Pointer
std::initializer_list< detail::json_ref< basic_json > > initializer_list_t
bool contains(KeyType &&key) const
check the existence of an element in a JSON object
static void to_cbor(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a CBOR serialization of a given JSON value
static void to_bson(const basic_json &j, detail::output_adapter< char > o)
create a BSON serialization of a given JSON value
iterator find(const typename object_t::key_type &key)
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init)
explicitly create a binary array (without subtype)
static std::vector< std::uint8_t > to_bjdata(const basic_json &j, const bool use_size=false, const bool use_type=false, const bjdata_version_t version=bjdata_version_t::draft2)
create a BJData serialization of a given JSON value
const_reference at(KeyType &&key) const
access specified object element with bounds checking
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json meta()
returns version information on the library
basic_json(size_type cnt, const basic_json &val)
construct an array with count copies of given value
const_iterator find(const typename object_t::key_type &key) const
find an element in a JSON object
static std::vector< std::uint8_t > to_cbor(const basic_json &j)
create a CBOR serialization of a given JSON value
IteratorType erase(IteratorType pos)
remove element given an iterator
iterator insert(const_iterator pos, const basic_json &val)
inserts element into array
ValueType value(const typename object_t::key_type &key, const ValueType &default_value) const
access specified object element with default value
std::allocator< basic_json > allocator_type
typename std::allocator_traits< allocator_type >::pointer pointer
string_t dump(const int indent=-1, const char indent_char=' ', const bool ensure_ascii=false, const error_handler_t error_handler=error_handler_t::strict) const
serialization
void merge_patch(const basic_json &apply_patch)
applies a JSON Merge Patch
ValueType & get_to(ValueType &v) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), v)))
get a value (explicit)
static void to_bjdata(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false, const bjdata_version_t version=bjdata_version_t::draft2)
create a BJData serialization of a given JSON value
reference operator[](T *key)
reference at(size_type idx)
access specified array element with bounds checking
iterator find(KeyType &&key)
find an element in a JSON object
constexpr bool is_number_float() const noexcept
reverse_iterator rend() noexcept
returns an iterator to the reverse-end
static std::vector< std::uint8_t > to_ubjson(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
reference at(const json_pointer &ptr)
access specified element via JSON Pointer
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json diff(const basic_json &source, const basic_json &target, const string_t &path="")
creates a diff as a JSON patch
std::less< std::string > default_object_comparator_t
reference operator+=(const typename object_t::value_type &val)
add an object to an object
const_iterator cbegin() const noexcept
reference operator[](typename object_t::key_type key)
access specified object element
constexpr auto get_ptr() const noexcept -> decltype(std::declval< const basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
~basic_json() noexcept
destructor
detail::out_of_range out_of_range
const_reverse_iterator crend() const noexcept
basic_json(initializer_list_t init, bool type_deduction=true, value_t manual_type=value_t::array)
create a container (array or object) from an initializer list
void swap(typename binary_t::container_type &other)
exchanges the values
binary_t & get_binary()
get a binary value
const_iterator begin() const noexcept
returns an iterator to the first element
constexpr bool is_number() const noexcept
void insert(const_iterator first, const_iterator last)
inserts range of elements into object
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
auto get() noexcept -> decltype(std::declval< basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
const_reference operator[](T *key) const
reference operator[](size_type idx)
access specified array element
basic_json(const JsonRef &ref)
adl_serializer< T, SFINAE > json_serializer
basic_json & operator=(basic_json other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value &&std::is_nothrow_move_assignable< json_base_class_t >::value)
copy assignment
static iteration_proxy< iterator > iterator_wrapper(reference ref) noexcept
static void to_ubjson(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Array get_to(T(&v)[N]) const noexcept(noexcept(JSONSerializer< Array >::from_json(std::declval< const basic_json_t & >(), v)))
std::int64_t number_integer_t
auto get_ptr() noexcept -> decltype(std::declval< basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
const_reference at(const typename object_t::key_type &key) const
access specified object element with bounds checking
constexpr bool is_binary() const noexcept
void swap(object_t &other)
exchanges the values
basic_json unflatten() const
unflatten a previously flattened JSON value
iterator insert(const_iterator pos, initializer_list_t ilist)
inserts elements from initializer list into array
static void to_bjdata(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false, const bjdata_version_t version=bjdata_version_t::draft2)
create a BJData serialization of a given JSON value
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
iteration_proxy< iterator > items() noexcept
helper to access iterator member functions in range-based for
bool empty() const noexcept
checks whether the container is empty.
void swap(array_t &other)
exchanges the values
void erase(const size_type idx)
remove element from a JSON array given an index
reference operator+=(basic_json &&val)
add an object to an array
bool contains(const json_pointer &ptr) const
check the existence of an element in a JSON object given a JSON pointer
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
reference emplace_back(Args &&... args)
add an object to an array
ValueType value(const json_pointer &ptr, const ValueType &default_value) const
access specified object element via JSON Pointer with default value
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json array(initializer_list_t init={})
explicitly create an array from an initializer list
detail::bjdata_version_t bjdata_version_t
friend class ::nlohmann::detail::parser
void push_back(const basic_json &val)
add an object to an array
ValueType value(KeyType &&key, const ValueType &default_value) const
access specified object element with default value
reference at(const typename object_t::key_type &key)
access specified object element with bounds checking
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
const_reverse_iterator crbegin() const noexcept
json_sax< basic_json > json_sax_t
constexpr bool is_boolean() const noexcept
size_type count(const typename object_t::key_type &key) const
returns the number of occurrences of a key in a JSON object
reference front()
access the first element
constexpr bool is_primitive() const noexcept
return whether type is primitive
constexpr bool is_null() const noexcept
void clear() noexcept
clears the contents
static void to_ubjson(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
detail::other_error other_error
basic_json(basic_json &&other) noexcept
move constructor
iter_impl< basic_json > iterator
basic_json(const value_t v)
create an empty value with a given type
const_reference operator[](size_type idx) const
access specified array element
std::ptrdiff_t difference_type
iterator insert(const_iterator pos, basic_json &&val)
inserts element into array
const_reverse_iterator rend() const noexcept
returns an iterator to the reverse-end
std::uint64_t number_unsigned_t
friend std::istream & operator>>(std::istream &i, basic_json &j)
static std::vector< std::uint8_t > to_msgpack(const basic_json &j)
create a MessagePack serialization of a given JSON value
void swap(string_t &other)
exchanges the values
basic_json(const BasicJsonType &val)
create a JSON value from an existing one
json_reverse_iterator< typename basic_json::iterator > reverse_iterator
const_reference at(size_type idx) const
access specified array element with bounds checking
detail::actual_object_comparator_t< basic_json > object_comparator_t
basic_json(const basic_json &other)
copy constructor
void push_back(const typename object_t::value_type &val)
add an object to an object
std::pair< iterator, bool > emplace(Args &&... args)
add an object to an object if key does not exist
static void to_cbor(const basic_json &j, detail::output_adapter< char > o)
create a CBOR serialization of a given JSON value
constexpr bool is_object() const noexcept
static void to_msgpack(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a MessagePack serialization of a given JSON value
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
iterator insert_iterator(const_iterator pos, Args &&... args)
basic_json(InputIT first, InputIT last)
construct a JSON container given an iterator range
bool contains(const typename object_t::key_type &key) const
check the existence of an element in a JSON object
static void to_bson(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a BSON serialization of a given JSON value
const_iterator find(KeyType &&key) const
find an element in a JSON object
::nlohmann::json_pointer< std::string > json_pointer
bool operator!=(const byte_container_with_subtype &rhs) const
byte_container_with_subtype() noexcept(noexcept(container_type()))
std::uint64_t subtype_type
bool operator==(const byte_container_with_subtype &rhs) const
BinaryType container_type
byte_container_with_subtype(container_type &&b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))))
byte_container_with_subtype(container_type &&b) noexcept(noexcept(container_type(std::move(b))))
constexpr subtype_type subtype() const noexcept
return the binary subtype
byte_container_with_subtype(const container_type &b, subtype_type subtype_) noexcept(noexcept(container_type(b)))
constexpr bool has_subtype() const noexcept
return whether the value has a subtype
byte_container_with_subtype(const container_type &b) noexcept(noexcept(container_type(b)))
void set_subtype(subtype_type subtype_) noexcept
sets the binary subtype
void clear_subtype() noexcept
clears the binary subtype
deserialization of CBOR, MessagePack, and UBJSON values
binary_reader(const binary_reader &)=delete
binary_reader(binary_reader &&)=default
binary_reader(InputAdapterType &&adapter, const input_format_t format=input_format_t::json) noexcept
create a binary reader
binary_reader & operator=(const binary_reader &)=delete
bool sax_parse(const input_format_t format, json_sax_t *sax_, const bool strict=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
binary_reader & operator=(binary_reader &&)=default
void write_bson(const BasicJsonType &j)
static constexpr CharType to_char_type(std::uint8_t x) noexcept
void write_ubjson(const BasicJsonType &j, const bool use_count, const bool use_type, const bool add_prefix=true, const bool use_bjdata=false, const bjdata_version_t bjdata_version=bjdata_version_t::draft2)
static CharType to_char_type(std::uint8_t x) noexcept
binary_writer(output_adapter_t< CharType > adapter)
create a binary writer
static constexpr CharType to_char_type(InputCharType x) noexcept
void write_msgpack(const BasicJsonType &j)
void write_cbor(const BasicJsonType &j)
general exception of the basic_json class
exception(int id_, const char *what_arg)
const int id
the id of the exception
static std::string diagnostics(std::nullptr_t)
static std::string name(const std::string &ename, int id_)
const char * what() const noexcept override
returns the explanatory string
static std::string diagnostics(const BasicJsonType *leaf_element)
exception indicating errors with iterators
static invalid_iterator create(int id_, const std::string &what_arg, BasicJsonContext context)
iter_impl operator+(difference_type i) const
add to iterator
iter_impl & operator=(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting assignment
bool operator>=(const iter_impl &other) const
comparison: greater than or equal
iter_impl(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting constructor
bool operator<(const iter_impl &other) const
comparison: smaller
bool operator<=(const iter_impl &other) const
comparison: less than or equal
iter_impl & operator-=(difference_type i)
subtract from iterator
iter_impl & operator--()
pre-decrement (–it)
const object_t::key_type & key() const
return the key of an object iterator
bool operator==(const IterImpl &other) const
comparison: equal
iter_impl operator++(int) &
post-increment (it++)
iter_impl & operator+=(difference_type i)
add to iterator
reference operator[](difference_type n) const
access to successor
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_pointer, typename BasicJsonType::pointer >::type pointer
typename BasicJsonType::difference_type difference_type
pointer operator->() const
dereference the iterator
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
difference_type operator-(const iter_impl &other) const
return difference
iter_impl(iter_impl &&) noexcept=default
std::bidirectional_iterator_tag iterator_category
friend iter_impl operator+(difference_type i, const iter_impl &it)
addition of distance and iterator
reference value() const
return the value of an iterator
bool operator>(const iter_impl &other) const
comparison: greater than
iter_impl & operator++()
pre-increment (++it)
typename BasicJsonType::value_type value_type
reference operator*() const
return a reference to the value pointed to by the iterator
iter_impl operator-(difference_type i) const
subtract from iterator
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_reference, typename BasicJsonType::reference >::type reference
iter_impl & operator=(const iter_impl< const BasicJsonType > &other) noexcept
converting assignment
bool operator!=(const IterImpl &other) const
comparison: not equal
iter_impl operator--(int) &
post-decrement (it–)
iter_impl(const iter_impl< const BasicJsonType > &other) noexcept
const copy constructor
void set_end() noexcept
set the iterator past the last value
iteration_proxy_value operator++(int) &
iteration_proxy_value(iteration_proxy_value const &)=default
bool operator==(const iteration_proxy_value &o) const
equality operator (needed for InputIterator)
bool operator!=(const iteration_proxy_value &o) const
inequality operator (needed for range-based for)
std::ptrdiff_t difference_type
iteration_proxy_value(IteratorType it, std::size_t array_index_=0) noexcept(std::is_nothrow_move_constructible< IteratorType >::value &&std::is_nothrow_default_constructible< string_type >::value)
iteration_proxy_value & operator++()
increment operator (needed for range-based for)
iteration_proxy_value()=default
std::forward_iterator_tag iterator_category
iteration_proxy_value value_type
iteration_proxy_value(iteration_proxy_value &&) noexcept(std::is_nothrow_move_constructible< IteratorType >::value &&std::is_nothrow_move_constructible< string_type >::value)=default
IteratorType::reference value() const
return value of the iterator
const string_type & key() const
return key of the iterator
iteration_proxy_value & operator=(iteration_proxy_value const &)=default
typename std::remove_cv< typename std::remove_reference< decltype(std::declval< IteratorType >().key()) >::type >::type string_type
proxy class for the items() function
iteration_proxy_value< IteratorType > end() const noexcept
return iterator end (needed for range-based for)
iteration_proxy(iteration_proxy const &)=default
iteration_proxy()=default
iteration_proxy(iteration_proxy &&) noexcept=default
iteration_proxy_value< IteratorType > begin() const noexcept
return iterator begin (needed for range-based for)
iteration_proxy(typename IteratorType::reference cont) noexcept
construct iteration proxy from a container
iteration_proxy & operator=(iteration_proxy const &)=default
json_ref(json_ref &&) noexcept=default
json_ref(const value_type &value)
json_ref(value_type &&value)
value_type const & operator*() const
value_type const * operator->() const
json_ref(std::initializer_list< json_ref > init)
json_ref(Args &&... args)
value_type moved_or_copied() const
json_reverse_iterator operator++(int) &
post-increment (it++)
json_reverse_iterator operator--(int) &
post-decrement (it–)
json_reverse_iterator & operator++()
pre-increment (++it)
std::ptrdiff_t difference_type
json_reverse_iterator & operator+=(difference_type i)
add to iterator
reference operator[](difference_type n) const
access to successor
auto key() const -> decltype(std::declval< Base >().key())
return the key of an object iterator
difference_type operator-(const json_reverse_iterator &other) const
return difference
typename Base::reference reference
the reference type for the pointed-to element
reference value() const
return the value of an iterator
json_reverse_iterator(const base_iterator &it) noexcept
create reverse iterator from base class
json_reverse_iterator & operator--()
pre-decrement (–it)
std::reverse_iterator< Base > base_iterator
shortcut to the reverse iterator adapter
json_reverse_iterator operator-(difference_type i) const
subtract from iterator
json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
create reverse iterator from iterator
json_reverse_iterator operator+(difference_type i) const
add to iterator
typename BasicJsonType::number_unsigned_t number_unsigned_t
bool number_integer(number_integer_t)
bool start_array(std::size_t=detail::unknown_size())
bool number_unsigned(number_unsigned_t)
bool start_object(std::size_t=detail::unknown_size())
typename BasicJsonType::binary_t binary_t
bool number_float(number_float_t, const string_t &)
bool parse_error(std::size_t, const std::string &, const detail::exception &)
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::number_float_t number_float_t
typename BasicJsonType::string_t string_t
bool start_array(std::size_t len)
typename BasicJsonType::parser_callback_t parser_callback_t
typename BasicJsonType::parse_event_t parse_event_t
json_sax_dom_callback_parser & operator=(json_sax_dom_callback_parser &&)=default
bool number_integer(number_integer_t val)
bool parse_error(std::size_t, const std::string &, const Exception &ex)
typename BasicJsonType::number_float_t number_float_t
json_sax_dom_callback_parser & operator=(const json_sax_dom_callback_parser &)=delete
lexer< BasicJsonType, InputAdapterType > lexer_t
bool number_unsigned(number_unsigned_t val)
bool number_float(number_float_t val, const string_t &)
constexpr bool is_errored() const
json_sax_dom_callback_parser(BasicJsonType &r, parser_callback_t cb, const bool allow_exceptions_=true, lexer_t *lexer_=nullptr)
bool binary(binary_t &val)
typename BasicJsonType::string_t string_t
bool string(string_t &val)
json_sax_dom_callback_parser(json_sax_dom_callback_parser &&)=default
typename BasicJsonType::number_unsigned_t number_unsigned_t
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::binary_t binary_t
~json_sax_dom_callback_parser()=default
bool start_object(std::size_t len)
json_sax_dom_callback_parser(const json_sax_dom_callback_parser &)=delete
SAX implementation to create a JSON value from SAX events
bool number_float(number_float_t val, const string_t &)
bool number_unsigned(number_unsigned_t val)
json_sax_dom_parser(const json_sax_dom_parser &)=delete
json_sax_dom_parser & operator=(const json_sax_dom_parser &)=delete
bool binary(binary_t &val)
typename BasicJsonType::binary_t binary_t
json_sax_dom_parser(BasicJsonType &r, const bool allow_exceptions_=true, lexer_t *lexer_=nullptr)
bool start_object(std::size_t len)
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::string_t string_t
~json_sax_dom_parser()=default
typename BasicJsonType::number_unsigned_t number_unsigned_t
bool parse_error(std::size_t, const std::string &, const Exception &ex)
lexer< BasicJsonType, InputAdapterType > lexer_t
bool start_array(std::size_t len)
typename BasicJsonType::number_float_t number_float_t
json_sax_dom_parser(json_sax_dom_parser &&)=default
constexpr bool is_errored() const
bool string(string_t &val)
json_sax_dom_parser & operator=(json_sax_dom_parser &&)=default
bool number_integer(number_integer_t val)
JSON_HEDLEY_RETURNS_NON_NULL static JSON_HEDLEY_CONST const char * token_type_name(const token_type t) noexcept
return name of values of type token_type (only used for errors)
token_type
token types for the parser
@ value_float
an floating point number – use get_number_float() for actual value
@ begin_array
the character for array begin [
@ value_string
a string – use get_string() for actual value
@ end_array
the character for array end ]
@ uninitialized
indicating the scanner is uninitialized
@ parse_error
indicating a parse error
@ value_integer
a signed integer – use get_number_integer() for actual value
@ value_separator
the value separator ,
@ end_object
the character for object end }
@ literal_true
the true literal
@ begin_object
the character for object begin {
@ value_unsigned
an unsigned integer – use get_number_unsigned() for actual value
@ literal_null
the null literal
@ end_of_input
indicating the end of the input buffer
@ name_separator
the name separator :
@ literal_or_value
a literal or the begin of a value (only for diagnostics)
@ literal_false
the false literal
bool skip_bom()
skip the UTF-8 byte order mark
lexer(InputAdapterType &&adapter, bool ignore_comments_=false) noexcept
JSON_HEDLEY_RETURNS_NON_NULL constexpr const char * get_error_message() const noexcept
return syntax error message
std::string get_token_string() const
constexpr number_integer_t get_number_integer() const noexcept
return integer value
constexpr position_t get_position() const noexcept
return position of last read token
constexpr number_unsigned_t get_number_unsigned() const noexcept
return unsigned integer value
typename lexer_base< BasicJsonType >::token_type token_type
lexer & operator=(lexer &&)=default
lexer(const lexer &)=delete
lexer & operator=(lexer &)=delete
string_t & get_string()
return current string value (implicitly resets the token; useful only once)
constexpr number_float_t get_number_float() const noexcept
return floating-point value
exception indicating other library errors
static other_error create(int id_, const std::string &what_arg, BasicJsonContext context)
exception indicating access out of the defined range
static out_of_range create(int id_, const std::string &what_arg, BasicJsonContext context)
output_adapter(StringType &s)
output_adapter(std::basic_ostream< CharType > &s)
output_adapter(std::vector< CharType, AllocatorType > &vec)
output adapter for output streams
void write_characters(const CharType *s, std::size_t length) override
output_stream_adapter(std::basic_ostream< CharType > &s) noexcept
void write_character(CharType c) override
output adapter for basic_string
void write_character(CharType c) override
output_string_adapter(StringType &s) noexcept
void write_characters(const CharType *s, std::size_t length) override
output adapter for byte vectors
output_vector_adapter(std::vector< CharType, AllocatorType > &vec) noexcept
void write_characters(const CharType *s, std::size_t length) override
void write_character(CharType c) override
exception indicating a parse error
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, BasicJsonContext context)
create a parse error exception
static parse_error create(int id_, std::size_t byte_, const std::string &what_arg, BasicJsonContext context)
const std::size_t byte
byte index of the parse error
void parse(const bool strict, BasicJsonType &result)
public parser interface
bool accept(const bool strict=true)
public accept interface
bool sax_parse(SAX *sax, const bool strict=true)
parser(InputAdapterType &&adapter, parser_callback_t< BasicJsonType > cb=nullptr, const bool allow_exceptions_=true, const bool ignore_comments=false, const bool ignore_trailing_commas_=false)
a parser reading from an input adapter
primitive_iterator_t & operator++() noexcept
primitive_iterator_t & operator-=(difference_type n) noexcept
constexpr bool is_begin() const noexcept
return whether the iterator can be dereferenced
primitive_iterator_t & operator--() noexcept
void set_end() noexcept
set iterator to a defined past the end
friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
constexpr bool is_end() const noexcept
return whether the iterator is at end
primitive_iterator_t operator++(int) &noexcept
primitive_iterator_t & operator+=(difference_type n) noexcept
friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
constexpr difference_type get_value() const noexcept
friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
primitive_iterator_t operator+(difference_type n) noexcept
void set_begin() noexcept
set iterator to a defined beginning
primitive_iterator_t operator--(int) &noexcept
std::array< char, 512 > string_buffer
string buffer
std::size_t bytes_after_last_accept
serializer(output_adapter_t< char > s, const char ichar, error_handler_t error_handler_=error_handler_t::strict)
JSON_PRIVATE_UNLESS_TESTED const bool ensure_ascii
std::size_t undumped_chars
const char thousands_sep
the locale's thousand separator character
const char decimal_point
the locale's decimal point character
serializer & operator=(const serializer &)=delete
const error_handler_t error_handler
error_handler how to react on decoding errors
string_t indent_string
the indentation string
const std::lconv * loc
the locale
serializer & operator=(serializer &&)=delete
std::array< char, 64 > number_buffer
a (hopefully) large enough character buffer
const char indent_char
the indentation character
void dump(const BasicJsonType &val, const bool pretty_print, const bool ensure_ascii, const unsigned int indent_step, const unsigned int current_indent=0)
internal implementation of the serialization function
serializer(const serializer &)=delete
serializer(serializer &&)=delete
exception indicating executing a member function with a wrong type
static type_error create(int id_, const std::string &what_arg, BasicJsonContext context)
JSON Pointer defines a string syntax for identifying a specific value within a JSON document
friend json_pointer operator/(const json_pointer &lhs, string_t token)
create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
typename string_t_helper< RefStringType >::type string_t
friend json_pointer operator/(const json_pointer &lhs, std::size_t array_idx)
create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
json_pointer(const string_t &s="")
create JSON pointer
bool empty() const noexcept
return whether pointer points to the root document
void pop_back()
remove last reference token
string_t to_string() const
return a string representation of the JSON pointer
json_pointer & operator/=(std::size_t array_idx)
append an array index at the end of this JSON pointer
void push_back(string_t &&token)
append an unescaped token at the end of the reference pointer
json_pointer & operator/=(const json_pointer &ptr)
append another JSON pointer at the end of this JSON pointer
friend json_pointer operator/(const json_pointer &lhs, const json_pointer &rhs)
create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
json_pointer parent_pointer() const
returns the parent of this JSON pointer
json_pointer & operator/=(string_t token)
append an unescaped reference token at the end of this JSON pointer
friend class json_pointer
const string_t & back() const
return last reference token
friend std::ostream & operator<<(std::ostream &o, const json_pointer &ptr)
write string representation of the JSON pointer to stream
void push_back(const string_t &token)
append an unescaped token at the end of the reference pointer
decltype( get< N >(std::declval< ::nlohmann::detail::iteration_proxy_value< IteratorType > >())) type
#define NLOHMANN_BASIC_JSON_TPL_DECLARATION
#define JSON_HEDLEY_CONST
#define JSON_HEDLEY_DIAGNOSTIC_PUSH
#define JSON_INLINE_VARIABLE
#define JSON_HEDLEY_WARN_UNUSED_RESULT
#define JSON_PRIVATE_UNLESS_TESTED
#define NLOHMANN_JSON_VERSION_PATCH
#define JSON_HEDLEY_LIKELY(expr)
bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
#define JSON_HEDLEY_NON_NULL(...)
#define JSON_INTERNAL_CATCH(exception)
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
#define JSON_HEDLEY_RETURNS_NON_NULL
#define JSON_CATCH(exception)
#define JSON_THROW(exception)
#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
#define NLOHMANN_JSON_VERSION_MAJOR
bool operator<(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
#define NLOHMANN_BASIC_JSON_TPL
#define JSON_HEDLEY_UNLIKELY(expr)
#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
#define NLOHMANN_JSON_NAMESPACE_END
#define JSON_NO_UNIQUE_ADDRESS
basic_json< nlohmann::ordered_map > ordered_json
specialization that maintains the insertion order of object keys
#define NLOHMANN_JSON_VERSION_MINOR
#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name)
bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
#define NLOHMANN_JSON_NAMESPACE_BEGIN
#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
#define JSON_HEDLEY_DIAGNOSTIC_POP
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result)
#define JSON_DIAGNOSTIC_POSITIONS
implements the Grisu2 algorithm for binary to decimal floating-point conversion.
int find_largest_pow10(const std::uint32_t n, std::uint32_t &pow10)
cached_power get_cached_power_for_binary_exponent(int e)
Target reinterpret_bits(const Source source)
boundaries compute_boundaries(FloatType value)
void grisu2_round(char *buf, int len, std::uint64_t dist, std::uint64_t delta, std::uint64_t rest, std::uint64_t ten_k)
void grisu2(char *buf, int &len, int &decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus)
void grisu2_digit_gen(char *buffer, int &length, int &decimal_exponent, diyfp M_minus, diyfp w, diyfp M_plus)
JSON_HEDLEY_RETURNS_NON_NULL char * append_exponent(char *buf, int e)
appends a decimal representation of e to buf
JSON_HEDLEY_RETURNS_NON_NULL char * format_buffer(char *buf, int len, int decimal_exponent, int min_exp, int max_exp)
prettify v = buf * 10^decimal_exponent
constexpr bool is_transparent()
constexpr bool is_c_string()
detail namespace with internal helper functions
make_integer_sequence< size_t, N > make_index_sequence
decltype(std::declval< StringType & >().append(std::declval< Arg && >())) string_can_append
std::integral_constant< bool,(std::is_signed< OfType >::value &&(sizeof(T)< sizeof(OfType)))||(same_sign< OfType, T >::value &&sizeof(OfType)==sizeof(T)) > never_out_of_range
input_format_t
the supported input formats
typename detector< nonesuch, void, Op, Args... >::type detected_t
void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence< Idx... >)
decltype(T::to_json(std::declval< Args >()...)) to_json_function
detector< Default, void, Op, Args... > detected_or
decltype(std::declval< T & >().binary(std::declval< Binary & >())) binary_function_t
typename std::conditional< is_usable_as_key_type< typename BasicJsonType::object_comparator_t, typename BasicJsonType::object_t::key_type, KeyTypeCVRef, RequireTransparentComparator, ExcludeObjectKeyType >::value &&!is_json_iterator_of< BasicJsonType, KeyType >::value, std::true_type, std::false_type >::type is_usable_as_basic_json_key_type
is_detected< string_can_append_data, StringType, Arg > detect_string_can_append_data
decltype(std::declval< T & >().end_object()) end_object_function_t
OutStringType concat(Args &&... args)
typename T::value_type value_type_t
constexpr std::array< T, sizeof...(Args)> make_array(Args &&... args)
JSON_HEDLEY_RETURNS_NON_NULL char * to_chars(char *first, const char *last, FloatType value)
generates a decimal representation of the floating-point number value in [first, last).
decltype(std::declval< T & >().boolean(std::declval< bool >())) boolean_function_t
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
is_detected< string_can_append, StringType, Arg > detect_string_can_append
typename std::enable_if< B, T >::type enable_if_t
@ value
the parser finished reading a JSON value
@ key
the parser read a key of a value in an object
@ array_end
the parser read ] and finished processing a JSON array
@ array_start
the parser read [ and started to process a JSON array
@ object_start
the parser read { and started to process a JSON object
@ object_end
the parser read } and finished processing a JSON object
std::integral_constant< bool, all_signed< Types... >::value||all_unsigned< Types... >::value > same_sign
typename detector< nonesuch, void, Op, Args... >::value_t is_detected
typename std::conditional< is_comparable< Comparator, ObjectKeyType, KeyTypeCVRef >::value &&!(ExcludeObjectKeyType &&std::is_same< KeyType, ObjectKeyType >::value) &&(!RequireTransparentComparator||is_detected< detect_is_transparent, Comparator >::value) &&!is_json_pointer< KeyType >::value, std::true_type, std::false_type >::type is_usable_as_key_type
typename T::pointer pointer_t
std::pair< A1, A2 > from_json_tuple_impl(BasicJsonType &&j, identity_tag< std::pair< A1, A2 > >, priority_tag< 0 >)
void from_json_array_impl(const BasicJsonType &j, typename BasicJsonType::array_t &arr, priority_tag< 3 >)
typename utility_internal::Gen< T, N >::type make_integer_sequence
conjunction< std::is_integral< Types >... > all_integral
std::shared_ptr< output_adapter_protocol< CharType > > output_adapter_t
a type to simplify interfaces
typename detected_or< Default, Op, Args... >::type detected_or_t
decltype(std::declval< T & >().key(std::declval< String & >())) key_function_t
decltype(std::declval< T & >().null()) null_function_t
void int_to_string(StringType &target, std::size_t value)
T conditional_static_cast(U value)
typename T::difference_type difference_type_t
conjunction< std::is_unsigned< Types >... > all_unsigned
constexpr T static_const< T >::value
decltype(std::declval< T & >().start_object(std::declval< std::size_t >())) start_object_function_t
decltype(std::declval< T & >().number_float( std::declval< Float >(), std::declval< const String & >())) number_float_function_t
void replace_substring(StringType &s, const StringType &f, const StringType &t)
replace all occurrences of a substring by another string
decltype(std::declval< T & >().start_array(std::declval< std::size_t >())) start_array_function_t
is_detected< string_can_append_iter, StringType, Arg > detect_string_can_append_iter
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
typename std::conditional< is_detected< detect_erase_with_key_type, typename BasicJsonType::object_t, KeyType >::value, std::true_type, std::false_type >::type has_erase_with_key_type
typename actual_object_comparator< BasicJsonType >::type actual_object_comparator_t
decltype(std::declval< ObjectType & >().erase(std::declval< KeyType >())) detect_erase_with_key_type
decltype(input_adapter(std::declval< const char * >(), std::declval< const char * >())) contiguous_bytes_input_adapter
bool little_endianness(int num=1) noexcept
determine system byte order
cbor_tag_handler_t
how to treat CBOR tags
@ store
store tags as binary type
@ error
throw a parse_error exception in case of a tag
value_type_t< iterator_traits< iterator_t< T > > > range_value_t
make_index_sequence< sizeof...(Ts)> index_sequence_for
void concat_into(OutStringType &)
constexpr bool value_in_range_of(T val)
value_t
the JSON type enumeration
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)
decltype(T::from_json(std::declval< Args >()...)) from_json_function
conjunction< std::is_signed< Types >... > all_signed
constexpr std::size_t unknown_size()
std::array< T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType &&j, identity_tag< std::array< T, sizeof...(Idx)> >, index_sequence< Idx... >)
StringType to_string(std::size_t value)
std::size_t hash(const BasicJsonType &j)
hash a JSON value
decltype(std::declval< T & >().number_integer(std::declval< Integer >())) number_integer_function_t
void unescape(StringType &s)
string unescaping as described in RFC 6901 (Sect. 4)
typename make_void< Ts... >::type void_t
std::size_t combine(std::size_t seed, std::size_t h) noexcept
decltype(std::declval< T & >().parse_error( std::declval< std::size_t >(), std::declval< const std::string & >(), std::declval< const Exception & >())) parse_error_function_t
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
iterator_input_adapter_factory< IteratorType >::adapter_type input_adapter(IteratorType first, IteratorType last)
enable_if_t< is_range< R >::value, result_of_begin< decltype(std::declval< R & >())> > iterator_t
typename T::iterator_category iterator_category_t
typename std::conditional< std::is_same< T, void >::value, json_default_base, T >::type json_base_class
is_c_string< uncvref_t< T > > is_c_string_uncvref
error_handler_t
how to treat decoding errors
@ strict
throw a type_error exception in case of invalid UTF-8
@ ignore
ignore invalid UTF-8 sequences
@ replace
replace invalid UTF-8 sequences with U+FFFD
std::size_t concat_length()
std::integral_constant< bool, Value > bool_constant
decltype(input_adapter(std::declval< std::string >())) string_input_adapter_type
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
void from_json(const BasicJsonType &j, typename std::nullptr_t &n)
typename T::key_compare detect_key_compare
void to_json(BasicJsonType &j, T b) noexcept
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
integer_sequence< size_t, Ints... > index_sequence
std::is_convertible< detected_t< Op, Args... >, To > is_detected_convertible
is_specialization_of<::nlohmann::json_pointer, uncvref_t< T > > is_json_pointer
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().begin(), std::declval< const Arg & >().end())) string_can_append_iter
decltype(std::declval< T & >().end_array()) end_array_function_t
std::tuple< Args... > from_json_tuple_impl_base(BasicJsonType &&j, index_sequence< Idx... >)
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().data(), std::declval< const Arg & >().size())) string_can_append_data
typename T::key_type key_type_t
typename T::reference reference_t
typename T::is_transparent detect_is_transparent
bjdata_version_t
how to encode BJData
is_detected< string_can_append_op, StringType, Arg > detect_string_can_append_op
typename T::mapped_type mapped_type_t
decltype(std::declval< StringType & >()+=std::declval< Arg && >()) string_can_append_op
StringType escape(StringType s)
string escaping as described in RFC 6901 (Sect. 4)
decltype(std::declval< T & >().string(std::declval< String & >())) string_function_t
decltype(std::declval< T >().template get< U >()) get_template_function
decltype(std::declval< T & >().number_unsigned(std::declval< Unsigned >())) number_unsigned_function_t
std::function< bool(int, parse_event_t, BasicJsonType &)> parser_callback_t
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression, cppcoreguidelines-noexcept-swap, performance-noexcept-swap) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
namespace for Niels Lohmann
static auto to_json(BasicJsonType &j, TargetType &&val) noexcept(noexcept(::nlohmann::to_json(j, std::forward< TargetType >(val)))) -> decltype(::nlohmann::to_json(j, std::forward< TargetType >(val)), void())
convert any value type to a JSON value
static auto from_json(BasicJsonType &&j) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))
convert a JSON value to any value type
static auto from_json(BasicJsonType &&j, TargetType &val) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), val))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), val), void())
convert a JSON value to any value type
typename BasicJsonType::object_t object_t
typename BasicJsonType::default_object_comparator_t object_comparator_t
typename std::conditional< has_key_compare< object_t >::value, typename object_t::key_compare, object_comparator_t >::type type
static constexpr int_type eof() noexcept
static char_type to_char_type(int_type i) noexcept
static int_type to_int_type(char_type c) noexcept
static char_type to_char_type(int_type i) noexcept
static constexpr int_type eof() noexcept
static int_type to_int_type(char_type c) noexcept
static diyfp mul(const diyfp &x, const diyfp &y) noexcept
returns x * y
static diyfp normalize_to(const diyfp &x, const int target_exponent) noexcept
normalize x such that the result has the exponent E
static diyfp normalize(diyfp x) noexcept
normalize x such that the significand is >= 2^(q-1)
static diyfp sub(const diyfp &x, const diyfp &y) noexcept
returns x - y
constexpr diyfp(std::uint64_t f_, int e_) noexcept
static constexpr int kPrecision
static void construct(BasicJsonType &j, const std::vector< bool > &arr)
static void construct(BasicJsonType &j, typename BasicJsonType::array_t &&arr)
static void construct(BasicJsonType &j, const typename BasicJsonType::array_t &arr)
static void construct(BasicJsonType &j, const CompatibleArrayType &arr)
static void construct(BasicJsonType &j, const std::valarray< T > &arr)
static void construct(BasicJsonType &j, const typename BasicJsonType::binary_t &b)
static void construct(BasicJsonType &j, typename BasicJsonType::binary_t &&b)
static void construct(BasicJsonType &j, typename BasicJsonType::boolean_t b) noexcept
static void construct(BasicJsonType &j, typename BasicJsonType::number_float_t val) noexcept
static void construct(BasicJsonType &j, typename BasicJsonType::number_integer_t val) noexcept
static void construct(BasicJsonType &j, typename BasicJsonType::number_unsigned_t val) noexcept
static void construct(BasicJsonType &j, const typename BasicJsonType::object_t &obj)
static void construct(BasicJsonType &j, const CompatibleObjectType &obj)
static void construct(BasicJsonType &j, typename BasicJsonType::object_t &&obj)
static void construct(BasicJsonType &j, typename BasicJsonType::string_t &&s)
static void construct(BasicJsonType &j, const CompatibleStringType &str)
static void construct(BasicJsonType &j, const typename BasicJsonType::string_t &s)
auto operator()(const BasicJsonType &j, T &&val) const noexcept(noexcept(from_json(j, std::forward< T >(val)))) -> decltype(from_json(j, std::forward< T >(val)))
typename BasicJsonType::template json_serializer< T, void > serializer
static constexpr bool value
typename BasicJsonType::template json_serializer< T, void > serializer
static constexpr bool value
static constexpr bool value
typename BasicJsonType::template json_serializer< T, void > serializer
static constexpr std::size_t size() noexcept
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
primitive_iterator_t primitive_iterator
generic iterator for all other types
BasicJsonType::object_t::iterator object_iterator
iterator for JSON objects
static constexpr bool value
static constexpr auto value
std::numeric_limits< RealIntegerType > RealLimits
std::numeric_limits< CompatibleNumberIntegerType > CompatibleLimits
typename BasicJsonType::object_t object_t
static constexpr bool value
static constexpr auto value
static constexpr bool value
detail::is_constructible_array_type_impl< BasicJsonType, ConstructibleArrayType, enable_if_t< !std::is_same< ConstructibleArrayType, typename BasicJsonType::value_type >::value &&!is_compatible_string_type< BasicJsonType, ConstructibleArrayType >::value &&is_default_constructible< ConstructibleArrayType >::value &&(std::is_move_assignable< ConstructibleArrayType >::value||std::is_copy_assignable< ConstructibleArrayType >::value)&&is_detected< iterator_t, ConstructibleArrayType >::value &&is_iterator_traits< iterator_traits< detected_t< iterator_t, ConstructibleArrayType > > >::value &&is_detected< range_value_t, ConstructibleArrayType >::value &&!std::is_same< ConstructibleArrayType, detected_t< range_value_t, ConstructibleArrayType > >::value &&is_complete_type< detected_t< range_value_t, ConstructibleArrayType > >::value > >::value_type range_value_t< ConstructibleArrayType > value_type
detail::is_constructible_array_type_impl< BasicJsonType, ConstructibleArrayType, enable_if_t< !std::is_same< ConstructibleArrayType, typename BasicJsonType::value_type >::value &&!is_compatible_string_type< BasicJsonType, ConstructibleArrayType >::value &&is_default_constructible< ConstructibleArrayType >::value &&(std::is_move_assignable< ConstructibleArrayType >::value||std::is_copy_assignable< ConstructibleArrayType >::value)&&is_detected< iterator_t, ConstructibleArrayType >::value &&is_iterator_traits< iterator_traits< detected_t< iterator_t, ConstructibleArrayType > > >::value &&is_detected< range_value_t, ConstructibleArrayType >::value &&!std::is_same< ConstructibleArrayType, detected_t< range_value_t, ConstructibleArrayType > >::value &&is_complete_type< detected_t< range_value_t, ConstructibleArrayType > >::value > >::value static constexpr bool value
typename BasicJsonType::object_t object_t
static constexpr bool value
ConstructibleStringType laundered_type
static constexpr auto value
static constexpr bool value
typename std::iterator_traits< T >::value_type value_type
static constexpr auto value
static one test(decltype(&C::capacity))
static constexpr bool value
static constexpr bool value
ptrdiff_t difference_type
std::random_access_iterator_tag iterator_category
typename It::iterator_category iterator_category
typename It::difference_type difference_type
typename It::value_type value_type
typename It::reference reference
typename It::pointer pointer
Default base class of the basic_json class.
nonesuch(nonesuch const &&)=delete
void operator=(nonesuch &&)=delete
void operator=(nonesuch const &)=delete
nonesuch(nonesuch const &)=delete
abstract output adapter interface
output_adapter_protocol(const output_adapter_protocol &)=default
virtual ~output_adapter_protocol()=default
virtual void write_character(CharType c)=0
output_adapter_protocol(output_adapter_protocol &&) noexcept=default
output_adapter_protocol()=default
virtual void write_characters(const CharType *s, std::size_t length)=0
struct to capture the start position of the current token
std::size_t chars_read_current_line
the number of characters read in the current line
std::size_t lines_read
the number of lines read
std::size_t chars_read_total
the total number of characters read
static JSON_INLINE_VARIABLE constexpr T value
auto operator()(BasicJsonType &j, T &&val) const noexcept(noexcept(to_json(j, std::forward< T >(val)))) -> decltype(to_json(j, std::forward< T >(val)), void())
integer_sequence< T, Ints...,(Ints+SeqSize)... > type
integer_sequence< T, Ints...,(Ints+SeqSize)..., 2 *SeqSize > type
integer_sequence< T > type
typename Extend< typename Gen< T, N/2 >::type, N/2, N % 2 >::type type
static constexpr bool test(T val)
static constexpr bool test(T)
static constexpr bool test(T val)
static constexpr bool test(T val)
static constexpr bool test(T val)
static constexpr bool test(T val)
virtual bool binary(binary_t &val)=0
a binary value was read
virtual bool number_float(number_float_t val, const string_t &s)=0
a floating-point number was read
virtual bool number_unsigned(number_unsigned_t val)=0
an unsigned integer number was read
virtual bool key(string_t &val)=0
an object key was read
virtual bool string(string_t &val)=0
a string value was read
virtual bool number_integer(number_integer_t val)=0
an integer number was read
virtual bool start_object(std::size_t elements)=0
the beginning of an object was read
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::string_t string_t
virtual bool end_array()=0
the end of an array was read
json_sax(const json_sax &)=default
virtual bool boolean(bool val)=0
a boolean value was read
virtual bool end_object()=0
the end of an object was read
typename BasicJsonType::number_float_t number_float_t
virtual bool null()=0
a null value was read
typename BasicJsonType::number_unsigned_t number_unsigned_t
json_sax(json_sax &&) noexcept=default
typename BasicJsonType::binary_t binary_t
virtual bool parse_error(std::size_t position, const std::string &last_token, const detail::exception &ex)=0
a parse error occurred
virtual bool start_array(std::size_t elements)=0
the beginning of an array was read
a minimal map-like container that preserves insertion order
std::vector< std::pair< const Key, T >, Allocator > Container
std::pair< iterator, bool > insert(value_type &&value)
typename Container::value_type value_type
std::equal_to< Key > key_compare
iterator erase(iterator pos)
ordered_map(const Allocator &alloc) noexcept(noexcept(Container(alloc)))
T & operator[](KeyType &&key)
typename Container::iterator iterator
const T & at(KeyType &&key) const
const T & operator[](KeyType &&key) const
iterator find(const key_type &key)
iterator erase(iterator first, iterator last)
const T & at(const key_type &key) const
const_iterator find(const key_type &key) const
T & operator[](const key_type &key)
size_type erase(KeyType &&key)
typename Container::size_type size_type
ordered_map() noexcept(noexcept(Container()))
void insert(InputIt first, InputIt last)
size_type count(const key_type &key) const
std::pair< iterator, bool > emplace(KeyType &&key, T &&t)
typename std::enable_if< std::is_convertible< typename std::iterator_traits< InputIt >::iterator_category, std::input_iterator_tag >::value >::type require_input_iter
size_type erase(const key_type &key)
ordered_map(std::initializer_list< value_type > init, const Allocator &alloc=Allocator())
std::pair< iterator, bool > insert(const value_type &value)
size_type count(KeyType &&key) const
ordered_map(It first, It last, const Allocator &alloc=Allocator())
const T & operator[](const key_type &key) const
iterator find(KeyType &&key)
T & at(const key_type &key)
typename Container::const_iterator const_iterator
std::pair< iterator, bool > emplace(const key_type &key, T &&t)
std::size_t operator()(const nlohmann::NLOHMANN_BASIC_JSON_TPL &j) const
bool operator()(::nlohmann::detail::value_t lhs, ::nlohmann::detail::value_t rhs) const noexcept
compare two value_t enum values